SA-MP Forums Archive
I'm getting errors in both cases. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: I'm getting errors in both cases. (/showthread.php?tid=313997)



I'm getting errors in both cases. - nuriel8833 - 28.01.2012

Hello
I've tried creating a script in 2 diffrent ways,in both ways I'm getting errors.
Way #1:
pawn Код:
if(RespawnDisabled = true)
    {
        new str[128];
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, killerid);
        IsPlayerSpectating[playerid] = true;
        format(str, 128, "~n~~n~~n~~n~~n~~n~~n~~n~~g~Spectating: ~w~%s(ID:%d)",    GetName(SpectatedPlayer[playerid]), SpectatedPlayer[playerid]);
        GameTextForPlayer(playerid,str,10000,3);
  }
Errors (all about the 'if' line):
pawn Код:
error 076: syntax error in the expression, or invalid function call
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Way #2
pawn Код:
if(RespawnDisabled == true)
    {
        new str[128];
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, killerid);
        IsPlayerSpectating[playerid] = true;
        format(str, 128, "~n~~n~~n~~n~~n~~n~~n~~n~~g~Spectating: ~w~%s(ID:%d)",    GetName(SpectatedPlayer[playerid]), SpectatedPlayer[playerid]);
        GameTextForPlayer(playerid,str,10000,3);
  }
Error (About the 'if' line too):
pawn Код:
error 076: syntax error in the expression, or invalid function call
Help please?


Re: I'm getting errors in both cases. - fiki574 - 28.01.2012

Ok, so is the "RespawnDisabled" define or bool?

Is it this:
pawn Код:
#define RespawnDisabled          true
or this:
pawn Код:
new bool:RespawnDisabled;



Re: I'm getting errors in both cases. - nuriel8833 - 28.01.2012

Quote:
Originally Posted by fiki574_CRO
Посмотреть сообщение
Ok, so is the "RespawnDisabled" define or bool?

Is it this:
pawn Код:
#define RespawnDisabled          true
or this:
pawn Код:
new bool:RespawnDisabled;
bool.


Re: I'm getting errors in both cases. - fiki574 - 28.01.2012

Try this:
pawn Код:
if(bool:RespawnDisabled == true)
{
        new str[128];
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, killerid);
        IsPlayerSpectating[playerid] = true;
        format(str, 128, "~n~~n~~n~~n~~n~~n~~n~~n~~g~Spectating: ~w~%s(ID:%d)",    GetName(SpectatedPlayer[playerid]), SpectatedPlayer[playerid]);
        GameTextForPlayer(playerid,str,10000,3);
}



Re: I'm getting errors in both cases. - nuriel8833 - 28.01.2012

Quote:
Originally Posted by fiki574_CRO
Посмотреть сообщение
Try this:
pawn Код:
if(bool:RespawnDisabled == true)
{
        new str[128];
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, killerid);
        IsPlayerSpectating[playerid] = true;
        format(str, 128, "~n~~n~~n~~n~~n~~n~~n~~n~~g~Spectating: ~w~%s(ID:%d)",    GetName(SpectatedPlayer[playerid]), SpectatedPlayer[playerid]);
        GameTextForPlayer(playerid,str,10000,3);
}
Nope still showing me the same error


Re: I'm getting errors in both cases. - fiki574 - 28.01.2012

Show me where you define this:
pawn Код:
IsPlayerSpectating[playerid] = true;



Re: I'm getting errors in both cases. - nuriel8833 - 28.01.2012

Quote:
Originally Posted by fiki574_CRO
Посмотреть сообщение
Show me where you define this:
pawn Код:
IsPlayerSpectating[playerid] = true;
pawn Код:
new bool:IsPlayerSpectating[MAX_PLAYERS];



Re: I'm getting errors in both cases. - fiki574 - 28.01.2012

Try this then:

pawn Код:
//replace your current bools
new bool:IsPlayerSpectating[MAX_PLAYERS] = false;
new bool:RespawnDisabled = true;
pawn Код:
if(bool:RespawnDisabled == true)
{
        new str[128];
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, killerid);
        IsPlayerSpectating[playerid] = true; //this line could cause the error
        //OR\\
        bool:IsPlayerSpectating[playerid] = true; //dont use both lines, just comment one
        format(str, 128, "~n~~n~~n~~n~~n~~n~~n~~n~~g~Spectating: ~w~%s(ID:%d)",    GetName(SpectatedPlayer[playerid]), SpectatedPlayer[playerid]);
        GameTextForPlayer(playerid,str,10000,3);
}



Respuesta: I'm getting errors in both cases. - kirk - 28.01.2012

if(bool:RespawnDisabled == true)

Just dont do this, it makes no sense.

Show us the code before that if statement.


Re: Respuesta: I'm getting errors in both cases. - nuriel8833 - 28.01.2012

Quote:
Originally Posted by kirk
Посмотреть сообщение
if(bool:RespawnDisabled == true)

Just dont do this, it makes no sense.

Show us the code before that if statement.
The other codes in the public or everything related to that?