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=443997)
OnPlayerKeyStateChange -
RALL0 - 14.06.2013
Hey guys, I've been trying to let zombies infect with a punch but I couldn't make it work, I wonder how I could make it actually work.
The codes
under OnPlayerKeyStateChange
pawn Код:
if((newkeys < oldkeys) && PlayerInfo[playerid][pZombie] == 1)
{
if(oldkeys - newkeys == KEY_FIRE)
{
new playerb;
new string[128];
if(PlayerInfo[playerb][pZombie] == 1) return 1;
if(Infected[playerb] == 1) return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}This player is already infected.");
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(!IsPlayerNearPlayer(playerid, playerb, 1.0))
{
GameTextForPlayer(playerb,"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~Infected~n~~w~Get An ~g~Antidote",3000,4);
Infected[playerb] = 1;
PlayerInfo[playerid][pInfects] += 1;
SetTimerEx("InfectedPlayer", 3000, true, "i", playerb);
format(string, sizeof(string), "* %s scratches %s, infecting them with the zombie virus.", RPN(playerid), RPN(playerb));
ProxDetector(30, playerid, string, COLOR_PURPLE);
}
}
}
Re: OnPlayerKeyStateChange -
KingHual - 14.06.2013
Код:
if(oldkeys - newkeys == KEY_FIRE)
You need to use bitwise AND here:
Код:
if (newkeys & KEY_FIRE)
Use the Wiki for reference:
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Re: OnPlayerKeyStateChange -
RALL0 - 14.06.2013
Yea, I replaced the codes but it's still not working. Is there something wrong with the rest?
Re: OnPlayerKeyStateChange -
KingHual - 14.06.2013
Код:
if((newkeys < oldkeys) && PlayerInfo[playerid][pZombie] == 1)
The first check is unneeded and, most likely, wrong.