OnPlayerKeyStateChange - 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: OnPlayerKeyStateChange (
/showthread.php?tid=660488)
OnPlayerKeyStateChange -
Longover - 04.11.2018
Hi!
I have a problem in my gamemode,when i type '2' or 'mmb' (key submission), i not give the message with "No suspects in range". how to solve it?
Code:
if((newkeys == KEY_SUBMISSION) && isLEO(playerid))
{
foreach(new i : Player)
{
new msg[100];
if(GetDistanceBetweenPlayers(playerid, i) < 7.0 && Player[i][playerWanted] < 6 && Player[i][playerWanted] != 0)
{
format(msg, 100, "/ticket %d", i);
return OnPlayerCommandReceived(playerid, msg);
}
if(GetDistanceBetweenPlayers(playerid, i) < 7.0 && Player[i][playerWanted] > 5)
{
format(msg, 100, "/arrest %d", i);
return OnPlayerCommandReceived(playerid, msg);
}
else
{
SendClientMessage(playerid, COLOR_RED, "No suspects in range.");
break;
}
}
}
if((newkeys == KEY_SUBMISSION) && IsNowTicketed[playerid] == true)
{
new msg[78];
format(msg, 100, "/payticket %d", TicketCop[playerid]);
return OnPlayerCommandReceived(playerid, msg);
}
Re: OnPlayerKeyStateChange -
v1k1nG - 04.11.2018
First of all that's not the way to check for keys
https://sampwiki.blast.hk/wiki/OnPlayer...heck_for_a_key
After you've done with that try debugging, after every if() use a print to see where the code is getting executed.
If you don't read a print that snippet isn't executed and so you need to edit your if()s.
Re: OnPlayerKeyStateChange -
khRamin78 - 05.11.2018
PHP Code:
if(newkeys & KEY_SUBMISSION)
{
if(!isLEO(playerid)) return 0;
foreach(new i : Player)
{
new msg[100];
if(GetDistanceBetweenPlayers(playerid, i) < 7.0 && Player[i][playerWanted] < 6 && Player[i][playerWanted] != 0)
{
format(msg, 100, "/ticket %d", i);
return OnPlayerCommandReceived(playerid, msg);
}
if(GetDistanceBetweenPlayers(playerid, i) < 7.0 && Player[i][playerWanted] > 5)
{
format(msg, 100, "/arrest %d", i);
return OnPlayerCommandReceived(playerid, msg);
}
else
{
SendClientMessage(playerid, COLOR_RED, "No suspects in range.");
break;
}
}
}
if(newkeys & KEY_SUBMISSION)
{
if(IsNowTicketed[playerid] == false) return 0;
new msg[78];
format(msg, 100, "/payticket %d", TicketCop[playerid]);
return OnPlayerCommandReceived(playerid, msg);
}
and you can use onplayercommandtext instead donno why you use commandreceived