13.07.2011, 09:05
Hello there..
I' m really sorry if such a question exists somewhere already.. But can someone please explain me how to work with global variables? I am starting to create a new script and i stopped by a HUGE problem..
I need a variable witch could contain a players ID so i could use it in more different functions..
I need a variable DRacer to keep the IDT value witch is targeted players ID so i could use IF command for /acceptrace so that only one who could accept is the player who i invited to race.. Where to define this variable?
And do i use it right way?-> new DRacer;
Here' s the script..
if (strcmp(cmd, "/race", true) == 0)
{
tmp = strtok(cmdtext,idx);
IDT = strval(tmp);
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInRangeOfPoint(IDT,6,x,y,z))
{
SendClientMessage(IDT, COLOR_RED, "You have been invited to race. Do you accept? /acceptrace");
DRacer = IDT;
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not near the player.");
return 1;
}
}
P.s. Tried to put it under --> public OnGameModeInit()
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(90) : warning 203: symbol is never used: "DRacer"
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : error 017: undefined symbol "DRacer"
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : warning 215: expression has no effect
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : error 001: expected token: ";", but found ")"
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : error 029: invalid expression, assumed zero
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : fatal error 107: too many error messages on one line
Best shoot is if i put it right before #if defined FILTERSCRIPT .. Then i get :
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(174) : warning 211: possibly unintended assignment
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(196) : warning 204: symbol is assigned a value that is never used: "DRacer"
Although i do use the value in other cmd -->
if (strcmp(cmd, "/acceptrace", true) == 0)
{
if (DRacer = playerid)
{
SendClientMessage(playerid, COLOR_RED, "Race will start at following location.");
SetPlayerCheckpoint(playerid,631.1714,-1724.1790,13.6263,2);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You have not been invited to a race.");
return 1;
}
}
Soo.. PLEASE!!!! if anyone could explain me wtf - i'd owe him like 100 hours of my life cos i' v spend already 3 nights tryin to figure this one out..
I' m really sorry if such a question exists somewhere already.. But can someone please explain me how to work with global variables? I am starting to create a new script and i stopped by a HUGE problem..
I need a variable witch could contain a players ID so i could use it in more different functions..
I need a variable DRacer to keep the IDT value witch is targeted players ID so i could use IF command for /acceptrace so that only one who could accept is the player who i invited to race.. Where to define this variable?
And do i use it right way?-> new DRacer;
Here' s the script..
if (strcmp(cmd, "/race", true) == 0)
{
tmp = strtok(cmdtext,idx);
IDT = strval(tmp);
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInRangeOfPoint(IDT,6,x,y,z))
{
SendClientMessage(IDT, COLOR_RED, "You have been invited to race. Do you accept? /acceptrace");
DRacer = IDT;
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not near the player.");
return 1;
}
}
P.s. Tried to put it under --> public OnGameModeInit()
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(90) : warning 203: symbol is never used: "DRacer"
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : error 017: undefined symbol "DRacer"
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : warning 215: expression has no effect
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : error 001: expected token: ";", but found ")"
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : error 029: invalid expression, assumed zero
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(175) : fatal error 107: too many error messages on one line
Best shoot is if i put it right before #if defined FILTERSCRIPT .. Then i get :
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(174) : warning 211: possibly unintended assignment
G:\N-Jay\Games\FOR SCRIPTING\Ravens_Roleplay_0.3c\Raven's Roleplay 0.3c\gamemodes\new.pwn(196) : warning 204: symbol is assigned a value that is never used: "DRacer"
Although i do use the value in other cmd -->
if (strcmp(cmd, "/acceptrace", true) == 0)
{
if (DRacer = playerid)
{
SendClientMessage(playerid, COLOR_RED, "Race will start at following location.");
SetPlayerCheckpoint(playerid,631.1714,-1724.1790,13.6263,2);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You have not been invited to a race.");
return 1;
}
}
Soo.. PLEASE!!!! if anyone could explain me wtf - i'd owe him like 100 hours of my life cos i' v spend already 3 nights tryin to figure this one out..