SA-MP Forums Archive
[HELP] Whats wrong? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Whats wrong? (/showthread.php?tid=133454)



[HELP] Whats wrong? - Thrarod - 12.03.2010

I made a wanted level color script for my CnR but Im new at scripting, whats wrong here?
Код:
public OnPlayerUpdate(playerid)
{
	new wantedlevel;
 	wantedlevel = GetPlayerWantedLevel(playerid);
	if wantedlevel =< 2 SetPlayerColor(COLOR_LIGHTRED);
	if wantedlevel => 3 SetPlayerColor(COLOR_RED);
	return 1;
}
And I get those errors
Код:
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(222) : warning 211: possibly unintended assignment
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(222) : error 029: invalid expression, assumed zero
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(222) : warning 215: expression has no effect
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(222) : error 001: expected token: ";", but found "-identifier-"
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(222) : warning 202: number of arguments does not match definition
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(223) : warning 211: possibly unintended assignment
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(223) : error 029: invalid expression, assumed zero
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(223) : warning 215: expression has no effect
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(223) : error 001: expected token: ";", but found "-identifier-"
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(223) : warning 202: number of arguments does not match definition
C:\Counter-Strike 2D\SampSrv\gamemodes\CnRTest.pwn(223) : warning 204: symbol is assigned a value that is never used: "wantedlevel"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Please help



Re: [HELP] Whats wrong? - Thrarod - 12.03.2010

Noone?


Re: [HELP] Whats wrong? - Jeffry - 12.03.2010

pawn Код:
public OnPlayerUpdate(playerid)
{
    new wantedlevel;
    wantedlevel = GetPlayerWantedLevel(playerid);
    if(wantedlevel =< 2) SetPlayerColor(COLOR_LIGHTRED);
    if(wantedlevel => 3) SetPlayerColor(COLOR_RED);
    return 1;
}
Try it.


Re: [HELP] Whats wrong? - ¤Adas¤ - 12.03.2010

It must be: >= and <=


Re: [HELP] Whats wrong? - aircombat - 12.03.2010

here is the right code
Код:
public OnPlayerUpdate(playerid)
{
    new wantedlevel;
    wantedlevel = GetPlayerWantedLevel(playerid);
    if(wantedlevel =< 2) 
    { 
    SetPlayerColor(COLOR_LIGHTRED);
    }
    else if(wantedlevel => 3)
    { 
    SetPlayerColor(COLOR_RED);
    }
    return 1;
}



Re: [HELP] Whats wrong? - Thrarod - 12.03.2010

None worked


Re: [HELP] Whats wrong? - Extremo - 12.03.2010

Thats because both of them forgot to actually include an ID.

SetPlayerColor(Color) is what they did, so where is the actual PLAYER-SELECTION.

Just ex-change the
pawn Код:
SetPlayerColor(COLOR);
with:
pawn Код:
SetPlayerColor(playerid, COLOR);
and it should work fine.


Re: [HELP] Whats wrong? - adsy - 12.03.2010

Quote:
Originally Posted by [NT
Extremo ]
Thats because both of them forgot to actually include an ID.

SetPlayerColor(Color) is what they did, so where is the actual PLAYER-SELECTION.

Just ex-change the
pawn Код:
SetPlayerColor(COLOR);
with:
pawn Код:
SetPlayerColor(playerid, COLOR);
and it should work fine.
and that

Quote:
Originally Posted by ¤Adas¤
It must be: >= and <=
Quote:
Originally Posted by [AC
Etch ]
here is the right code
Код:
public OnPlayerUpdate(playerid)
{
    new wantedlevel;
    wantedlevel = GetPlayerWantedLevel(playerid);
    if(wantedlevel =< 2) 
    { 
    SetPlayerColor(COLOR_LIGHTRED);
    }
    else if(wantedlevel => 3)
    { 
    SetPlayerColor(COLOR_RED);
    }
   return 1;
}
so still wrong

https://sampwiki.blast.hk/wiki/Scripting:tags#Operators


Re: [HELP] Whats wrong? - Extremo - 12.03.2010

Good one, didn't notice that. You can also memorize the order by actually thinking via the mathematical term. It is a < or > and under it is either a _ or a = so, first comes the above, then the below.

Like these:

or

(Credits to wikipedia & the makers for the pictures)