[Help] About fail else in if.. - 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] About fail else in if.. (
/showthread.php?tid=182607)
[Help] About fail else in if.. -
Kuba5 - 11.10.2010
Hi

.. i have problem with if in OnPlayerKeyStateChange for police on control closest players.. But when player (i) is wanted and he is close from police, so send SCM "Nobody in yours closer not wanted" + GameText "THIS PLAYER IS WANTED", but i want show only gametexts for police "THIS PLAYER IS WANTED" when player (i) is wanted and he is close from police. Sorry for poorly explained. Maybe you can understand from the script.
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_ACTION) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && iPlayerRole[playerid] == 4)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(GetDistanceBetweenPlayers(playerid, i) <= 10 && GetPlayerWantedLevel(i) >= 1 && i != playerid)
{
GameTextForPlayer(i,"~h~~w~Police want you to stop!~n~~r~STOP",5000,4 ); //message for wanted player from police
GameTextForPlayer(playerid,"~h~~r~This player is wanted!", 5000, 4); //message for police
lastcolor = GetPlayerColor(i);
SetPlayerMarkerForPlayer(playerid, i, COLOR_RED);
SetTimerEx("oldcolor", 5000, 0,"i",i); //in next public give wanted player his old color..
} else {
SendClientMessage(playerid, COLOR_BLUE, "Nobody in yours close not wanted");
}
}
}
return 1;
}
Re: [Help] About fail else in if.. -
Backwardsman97 - 11.10.2010
I really could not understand what you were asking. Try this though.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_ACTION) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && iPlayerRole[playerid] == 4)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(GetDistanceBetweenPlayers(playerid, i) <= 10 && GetPlayerWantedLevel(i) >= 1)
{
GameTextForPlayer(i,"~h~~w~Police want you to stop!~n~~r~STOP",5000,4 ); //message for wanted player from police
GameTextForPlayer(playerid,"~h~~r~This player is wanted!", 5000, 4); //message for police
lastcolor = GetPlayerColor(i);
SetPlayerMarkerForPlayer(playerid, i, COLOR_RED);
SetTimerEx("oldcolor", 5000, 0,"i",i); //in next public give wanted player his old color..
return 1;
}
}
SendClientMessage(playerid, COLOR_BLUE, "Nobody in yours close not wanted");
return 1;
}
}
Re: [Help] About fail else in if.. -
Finn - 11.10.2010
You had the message inside the loop itself, which made it spam. Simply put the text
after the loop and return the callback when you've found the wanted player.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_ACTION) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && iPlayerRole[playerid] == 4)
{
for(new i; i < MAX_PLAYERS; i++)
{
if(i == playerid || !IsPlayerConnected(i)) continue;
if(GetDistanceBetweenPlayers(playerid, i) <= 10.0)
{
if(0 < GetPlayerWantedLevel(i))
{
GameTextForPlayer(i, "~h~~w~Police want you to stop!~n~~r~STOP", 5000, 4); //message for wanted player from police
GameTextForPlayer(playerid, "~h~~r~This player is wanted!", 5000, 4); //message for police
lastcolor = GetPlayerColor(i);
SetPlayerMarkerForPlayer(playerid, i, COLOR_RED);
SetTimerEx("oldcolor", 5000, 0, "i", i); //in next public give wanted player his old color..
return 1;
}
}
}
SendClientMessage(playerid, COLOR_BLUE, "There aren't any wanted players near you.");
return 1;
}
return 1;
}
Edit: Sorry I was writing this post and didn't notice this thread was replied meanwhile.
Re: [Help] About fail else in if.. -
Kuba5 - 11.10.2010
Thank you very much boys.. .))