Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: kennedyarz on Mar 02, 2017, 05:04 PM

Title: [Client] GuiButton Crashed
Post by: kennedyarz on Mar 02, 2017, 05:04 PM
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
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FzyMnJ6c.png&hash=bf87b2cfc3ea68aeb07d970a0b4c6303921b033c)
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2Fpb3WgaO.png&hash=96288b8f52775afe147193c807be2073dfe6ee21)
Title: Re: [Client] GuiButton Crashed
Post by: . on Mar 02, 2017, 05:08 PM
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.
Title: Re: [Client] GuiButton Crashed
Post by: kennedyarz on Mar 02, 2017, 05:29 PM
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
Title: Re: [Client] GuiButton Crashed
Post by: Luis_Labarca on Mar 02, 2017, 07:45 PM
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)
}
}
Title: Re: [Client] GuiButton Crashed
Post by: KAKAN on Mar 03, 2017, 05:53 AM
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);
}
Title: Re: [Client] GuiButton Crashed
Post by: Luis_Labarca on Mar 03, 2017, 06:59 AM
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
Title: Re: [Client] GuiButton Crashed
Post by: 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...
Title: Re: [Client] GuiButton Crashed
Post by: kennedyarz on Mar 03, 2017, 01:47 PM
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
Title: Re: [Client] GuiButton Crashed
Post by: 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
Title: Re: [Client] GuiButton Crashed
Post by: 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"
Title: Re: [Client] GuiButton Crashed
Post by: 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
Title: Re: [Client] GuiButton Crashed
Post by: kennedyarz on Mar 03, 2017, 09:03 PM
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
Title: Re: [Client] GuiButton Crashed
Post by: Danix on Mar 04, 2017, 09:42 PM
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. ^^
Title: Re: [Client] GuiButton Crashed
Post by: Luis_Labarca on Mar 05, 2017, 02:54 AM
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
Title: Re: [Client] GuiButton Crashed
Post by: KAKAN on Mar 05, 2017, 05:24 AM
No, you're not. ElementRelease and ElementClick serve different purposes. I never knew ElementRelease was actually there :x
Title: Re: [Client] GuiButton Crashed
Post by: Luis_Labarca on Mar 05, 2017, 06:05 AM
Quote from: KAKAN on Mar 05, 2017, 05:24 AMNo, you're not. ElementRelease and ElementClick serve different purposes. I never knew ElementRelease was actually there :x
I do not know what to do. I think it was the GUI :: ElementClick I have it right just to give you the example start copying to do the example and do not notice that I had put in the ElementClick example and it was GUI :: ElementClick For the next when you go to give example I fixed well in the example that I will pass ;)
Title: Re: [Client] GuiButton Crashed
Post by: kennedyarz on Mar 07, 2017, 02:05 AM
Lol I forgot to block, the solution was, send data by pressing the close server button, and then from the server send data here Server :: ServerData (stream) in case example example: Stream.WriteString (4) and here at Case 4:
Blablabla <- null;