SA-MP Forums Archive
Crouch problem - 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: Crouch problem (/showthread.php?tid=406845)



Crouch problem - FL3GM4 - 11.01.2013

it kick me when i press once 'C' button but i want to kick me when i press it 5 times in row ...

Код:
SetTimer("ResetCrouchCount", 5000, true);
onplayerconnect
Код:
 	CrouchCount[playerid] = 0; // I don't think this is needed, but I put it anyways
onplayerupdate
Код:
	if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
	{
    	CrouchCount[playerid] ++;
    	if(CrouchCount[playerid] > 10)
    	{
        	SendClientMessage(playerid,-1,""#COL_RED"[WS:AC] "#COL_WHITE"Izbaceni ste zbog iskoristavanja "#COL_ORANGE"C-Bug"#COL_WHITE"-a");
        	return Kick(playerid);
    	}
	}
Код:
public ResetCrouchCount(playerid)
{
    CrouchCount[playerid] = 0;
}



Re: Crouch problem - Vince - 11.01.2013

Do you realize that OnPlayerUpdate is called up to 32 times a second? Your variable will be incremented 10 times in about 400 milliseconds. Hint: OnPlayerKeyStateChange.


Re: Crouch problem - FL3GM4 - 11.01.2013

but can i make that kicks players only if they have gun in hand !?

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
	{
    	CrouchCount[playerid] ++;
    	if(CrouchCount[playerid] > 10)
    	{
        	SendClientMessage(playerid,-1,""#COL_RED"[WS:AC] "#COL_WHITE"Izbaceni ste zbog iskoristavanja "#COL_ORANGE"C-Bug"#COL_WHITE"-a");
        	return Kick(playerid);
    	}
	}
	return 1;
}