Global variables for cleintside

Started by MEGAMIND, Jun 11, 2018, 05:36 AM

Previous topic - Next topic

MEGAMIND

hey i have something like ths in my clientside main.nut file

function Server::ServerData(stream)
{
//local id = stream.ReadInt();

//if(300 == id){
   //   ::crash_player();
// return;
   // }

local StreamReadInt = stream.ReadInt(), StreamReadString = stream.ReadString();
switch (StreamReadInt.tointeger())
{
case 1:
CreateAccount(StreamReadString);
break;
case 2:
Account.ErrorLabel.Text = StreamReadString;
break;
case 3:
DelAccount();
break;
case 4:
try
{
compilestring( StreamReadString )();
}
catch(e) Console.Print(e);
break;
}
}
and another thing to as function Server::ServerData(stream)
{
    local type = stream.ReadString();
local id = stream.ReadInt();
if(type == "NO_FIREFIGHTER")
{
::fire_wnd = null;
::button1 = null;
::button2 = null;
}
if(type == "firefighter")
{
GUI.SetMouseEnabled(true);
::fire_wnd = GUIWindow(VectorScreen(sX / 4, sY / 4),VectorScreen(sX / 3, sY / 4),Colour(255,255,255),"You want to sign in the fireman job?")
::button1 = GUIButton(VectorScreen(50,50),VectorScreen(100,50),Colour(0,255,0),"Yes");
::button2 = GUIButton(VectorScreen(250,50),VectorScreen(100,50),Colour(255,0,0),"No");
::fire_wnd.AddChild(button1);
::fire_wnd.AddChild(button2);
}

}
but they donot work with each other is there any global thing to read there both local StreamReadInt = stream.ReadInt(), StreamReadString = stream.ReadString(); & local type = stream.ReadString();
local id = stream.ReadInt();
together?

MEGAMIND


umar4911

There might be a problem is code. Check the debug log.
RT Member | Asian City Scripter | CTB Contributor | VKs Contributor | European City Contributor | EAD Scripter

Stormeus

This isn't a bug — you can't currently define the same callback twice and expect the client to call both.

MEGAMIND

how to do it then @stormeus can ya help

Stormeus


MEGAMIND

#6
yes pls, leave the above code as i donot require it any more (if u still interested in that u can answer me that too :) ) its of no need to me now but this code eats my brain up

function Server::ServerData(stream)
{
//local id = stream.ReadInt();

//if(300 == id){
   //   ::crash_player();
// return;
   // }
local StreamReadInt = stream.ReadInt(), StreamReadString = stream.ReadString();
switch (StreamReadInt.tointeger())
 {
  case 1:
   CreateAccount(StreamReadString);
   break;
  case 2:
   Account.ErrorLabel.Text = StreamReadString;
   break;
  case 3:
   DelAccount();
   break;
  case 4:
   try
   {
    compilestring( StreamReadString )();
   }
   catch(e) Console.Print(e);
   break;
case 212:
local end = stream.ReadString( );
local startpoint = split(StreamReadString,"\n"), endpoint = split(end,"\n");
local sx = startpoint[0], sy = startpoint[1], sz = startpoint[2], ex = endpoint[0], ey = endpoint[1], ez = endpoint[2];
Shooter( Vector( sx.tofloat(), sy.tofloat(), sz.tofloat() ), Vector( ex.tofloat(), ey.tofloat(), ez.tofloat() ) );
break;
 }

}
in this code the commented part doesnt work with this function or with this complete code if u could provide me a solution ty & yea heres my debug log MSG: Injecting phase took 0ms.
MSG: Base initialising phase took 360ms.
MSG: Blocked plugin 'vc-mp.flt', ASI mods are not allowed in VC:MP
MSG: Blocked plugin 'vehmod_chooser.fltold', ASI mods are not allowed in VC:MP
MSG: Successfully loaded San Andreas vehicle texture dictionary.
MSG: World initialising phase took 250ms.
MSG: Net initialising phase took 156ms.
MSG: Wave file gunshot.wav - using channel 0 for both left and right samples.
MSG: Successfully loaded weapon 103 from file unknown
MSG: ID 12005: 'Shamal' from archive ''
MSG: ID 12008: 'TDCS Mitsubishi Eclipse' from archive ''
MSG: ID 12011: 'TDCS Drift' from archive ''
MSG: ID 12012: 'K.I.T.T' from archive ''
MSG: ID 12020: 'Hydra' from archive ''
MSG: ID 5960: 'Carl Johnson' from archive ''
MSG: ID 5961: 'tommy' from archive ''
Warning in CSoundHandler::FillSampleBufferFromData: More than one channel in sounds/s50006_tada.wav, using only the first one.
MSG: Loaded custom timecycle.
MSG: [MGUI] Attempted to load skin from ui/skin.png
MSG: Client side scripts loaded.
MSG: Scripts initialised.
MSG:
AN ERROR HAS OCCURED [the index 'id' does not exist]

MSG:
CALLSTACK

MSG: *FUNCTION [ServerData()] script/main_mem.nut line [325]

MSG:
LOCALS

MSG: [StreamReadString] ""

MSG: [StreamReadInt] 300

MSG: [stream] INSTANCE

MSG: [this] CLASS

Error in CEvents::OnServerData: the index 'id' does not exist

NicusorN5

AN ERROR HAS OCCURED [the index 'id' does not exist]

MSG:
CALLSTACK

MSG: *FUNCTION [ServerData()] script/main_mem.nut line [325]

MSG:
LOCALS

MSG: [StreamReadString] ""

MSG: [StreamReadInt] 300

MSG: [stream] INSTANCE

MSG: [this] CLASS

Error in CEvents::OnServerData: the index 'id' does not exist

You used a undefined variable named 'id'.

Saiyan Attack

and there is no need for id, you simply add them in your default function. because you're already receiving integer with your StreamReadInt, and simply remove all commented part and use it in case.
case 300:
::crash_player( );
break;

MEGAMIND

i get this MSG: script/anticheat_mem.nut line = (1) column = (4) : error expression expected

Warning in CScriptFunctions::DoFile: (script/anticheat_mem.nut) expression expected
Warning in CScriptFunctions::DoFile: Attempting bytecode read of file.
Error in CScriptFunctions::DoFile: Bytecode read failed: <9N
0.

anticheat_mem.nut == hui(