[Client] GuiButton Crashed

Started by kennedyarz, Mar 02, 2017, 05:04 PM

Previous topic - Next topic

kennedyarz

I have A menu this menu for test
In Server Main
else if(cmd=="Test")
    {
Stream.StartWrite()
    Stream.WriteInt(3)
    Stream.SendStream(player)
}

In  Client-Side

function Server::ServerData( stream )
{
 local strint = stream.ReadInt( );
 
 switch( strint.tointeger( ) )
 {
  case 1:
::Test <- GUIButton(VectorScreen(400,200), VectorScreen(200, 22), Colour(75,75,75), "Python (6) Cost(3)", GUI_FLAG_BORDER | GUI_FLAG_VISIBLE);
::Test.TextColour = Colour(255, 255, 250);
break;
default: break;
}

function GUI::ElementClick(element, mouseX, mouseY)
{
if (element == Test)
{
::Test<-null;//Delete
Console.Print("[#A22ACC][M4] [#AC2211]Done")
::GUI.SetMouseEnabled(false);
}

Screen



.

#1
Server:
Stream.WriteInt(3)
Client:
local strint = stream.ReadInt( );
ReadInt() already returns an integers. Why do this?
switch( strint.tointeger( ) )
Streams are raw binary data not stuff converted to text. If they were text then they wouldn't be any different than sending a chat/command message.

And also. You sent `3` from the server but test for `1` on the client:
case 1:
So I'm not even sure how it ended up creating the GUI stuff.
.

kennedyarz

Quote from: happymint on Mar 02, 2017, 05:08 PMServer:
Stream.WriteInt(3)
Client:
local strint = stream.ReadInt( );
ReadInt() already returns an integers. Why do this?
switch( strint.tointeger( ) )
Streams are raw binary data not stuff converted to text. If they were text then they wouldn't be any different than sending a chat/command message.

And also. You sent `3` from the server but test for `1` on the client:
case 1:
So I'm not even sure how it ended up creating the GUI stuff.

Even my grandmother know that, I know that I put it there 3 I put it because I did not have time to modify, but that is perfect, the problem is because it crashes

Luis_Labarca

#3
I used to do that but I did it just like in this example and it works for me

//in client-side
function Server::ServerData(stream)
{
local String = stream.ReadString();
if(String=="DeleteTest")
{
::GUI.SetMouseEnabled(false);
::Test<-null;////
}
}
function GUI::ElementClick(element, mouseX, mouseY)
{
if (element == Test)
{
local s = Stream();
s.WriteString("DTest");
Server.SendData(s);
Console.Print("[#A22ACC][M4] [#AC2211]Done")
}
}
///in script server

function onClientScriptData(player)
{
local String = Stream.ReadString();
if( String =="DTest")
{
Stream.StartWrite()
Stream.WriteString("DeleteTest")
Stream.SendStream(player)
}
}
My server RP
IP: 51.222.28.159:8194

KAKAN

local s = Stream();
Datos.WriteString("DTest");
Server.SendData(s);

DAFUQ DID I JUST SEE?


Kenne, try:
function GUI::ElementClick(element, mouseX, mouseY)
{
if (element == ::Test)
{
::Test<-null;//Delete
Console.Print("[#A22ACC][M4] [#AC2211]Done")
SetMouseEnabled(false);
}
oh no

Luis_Labarca

Quote from: KAKAN on Mar 03, 2017, 05:53 AMlocal s = Stream();
Datos.WriteString("DTest");
Server.SendData(s);

DAFUQ DID I JUST SEE?


Kenne, try:
function GUI::ElementClick(element, mouseX, mouseY)
{
if (element == ::Test)
{
::Test<-null;//Delete
Console.Print("[#A22ACC][M4] [#AC2211]Done")
SetMouseEnabled(false);
}
:P That you just saw ??? I help my friend?

Tell your @kennedyarz I help you with that example I gave you or not

PD:Just because you know more than one you think that what makes others is SHIT
My server RP
IP: 51.222.28.159:8194

KAKAN

#6
Quote from: Luis_Labarca on Mar 03, 2017, 06:59 AMJust because you know more than one you think that what makes others is SHIT
Check your code. Give working versions if you want to help someone.
local s = Stream();
Datos.WriteString("DTest");
Server.SendData(s);
Datos is not defined. That means, you're sending a empty stream to the server, which I guess may crash VCMP server depending on what the devs have done.

Seriously, what's wrong with you people? Don't blame me, just take a look at your code before you post it. Some noob is going to use this code and complain you for not giving a working code...
oh no

kennedyarz

#7
Quote from: KAKAN on Mar 03, 2017, 08:11 AM
Quote from: Luis_Labarca on Mar 03, 2017, 06:59 AMJust because you know more than one you think that what makes others is SHIT
Check your code. Give working versions if you want to help someone.
local s = Stream();
Datos.WriteString("DTest");
Server.SendData(s);
Datos is not defined. That means, you're sending a empty stream to the server, which I guess may crash VCMP server depending on what the devs have done.

Seriously, what's wrong with you people? Don't blame me, just take a look at your code before you post it. Some noob is going to use this code and complain you for not giving a working code...

Really thank you, the truth that same crashes but, I'll leave it like that because it works perfect. thx @Luis_Labarca

Luis_Labarca

#8
Quote from: KAKAN on Mar 03, 2017, 08:11 AMOkay if I have made a mistake
Datos.WriteString("DTest"); is s.WriteString("DTest");

But everything else works well because I have it and I work well


@kennedyarz
Change
of
Data.WriteString ("DTest");
to
s.WriteString ("DTest");
           
That will work for you
My server RP
IP: 51.222.28.159:8194

kennedyarz

Quote from: Luis_Labarca on Mar 03, 2017, 02:43 PM
Quote from: KAKAN on Mar 03, 2017, 08:11 AMOkay if I have made a mistake
Datos.WriteString("DTest"); is s.WriteString("DTest");

But everything else works well because I have it and I work well


@kennedyarz
Change
of
Data.WriteString ("DTest");
to
s.WriteString ("DTest");
           
That will work for you

-_- What are you telling me? The only thing that is doing is to change the local variab. Bone "do nothing"

Luis_Labarca

Quote from: kennedyarz on Mar 03, 2017, 03:05 PM
Quote from: Luis_Labarca on Mar 03, 2017, 02:43 PM
Quote from: KAKAN on Mar 03, 2017, 08:11 AMOkay if I have made a mistake
Datos.WriteString("DTest"); is s.WriteString("DTest");

But everything else works well because I have it and I work well


@kennedyarz
Change
of
Data.WriteString ("DTest");
to
s.WriteString ("DTest");
           
That will work for you

-_- What are you telling me? The only thing that is doing is to change the local variab. Bone "do nothing"

-_-

local s = Stream();
Datos.WriteString("DTest");
Server.SendData(s);

change to

local s = Stream();
s.WriteString("DTest");
Server.SendData(s);

 :P
My server RP
IP: 51.222.28.159:8194

kennedyarz

Quote from: Luis_Labarca on Mar 03, 2017, 04:03 PM
Quote from: kennedyarz on Mar 03, 2017, 03:05 PM
Quote from: Luis_Labarca on Mar 03, 2017, 02:43 PM
Quote from: KAKAN on Mar 03, 2017, 08:11 AMOkay if I have made a mistake
Datos.WriteString("DTest"); is s.WriteString("DTest");

But everything else works well because I have it and I work well


@kennedyarz
Change
of
Data.WriteString ("DTest");
to
s.WriteString ("DTest");
           
That will work for you

-_- What are you telling me? The only thing that is doing is to change the local variab. Bone "do nothing"

-_-

local s = Stream();
Datos.WriteString("DTest");
Server.SendData(s);

change to

local s = Stream();
s.WriteString("DTest");
Server.SendData(s);

 :P

I knew you meant that, but it's the same, it does not change at all, you're just replacing a local

Danix

Try this:
function GUI::ElementRelease(element, mouseX, mouseY)
{
if (element == ::Test)
{
::Test<-null;//Delete
Console.Print("[#A22ACC][M4] [#AC2211]Done")
::GUI.SetMouseEnabled(false);
}
}
Using GUI::ElementRelease instead of GUI::ElementClick. ^^

Luis_Labarca

Quote from: Danix on Mar 04, 2017, 09:42 PMTry this:
function GUI::ElementRelease(element, mouseX, mouseY)
{
if (element == ::Test)
{
::Test<-null;//Delete
Console.Print("[#A22ACC][M4] [#AC2211]Done")
::GUI.SetMouseEnabled(false);
}
}
Using GUI::ElementRelease instead of GUI::ElementClick. ^^

Oh shit there also I was wrong and it's GUI::ElementClick I thought I had a good time
My server RP
IP: 51.222.28.159:8194

KAKAN

No, you're not. ElementRelease and ElementClick serve different purposes. I never knew ElementRelease was actually there :x
oh no