Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Includes
- #include <a_samp>
- // Variables
- new AntiSK[MAX_PLAYERS], AntiSKt[MAX_PLAYERS], AntiSKr[MAX_PLAYERS], AntiSKa[MAX_PLAYERS];
- #define FLOAT_INFINITY (0x7F800000)
- public OnFilterScriptInit()
- {
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SpawnProtect(playerid);
- return 1;
- }
- forward SpawnProtect(playerid);
- public SpawnProtect(playerid)
- {
- SetPlayerHealth(playerid, FLOAT_INFINITY);
- AntiSKr[playerid] = random(3);
- switch(AntiSKr[playerid])
- {
- case 0:
- {
- AntiSKa[playerid] = 10*1000; // 10 multiplied by 1000 mili-secs = 10 seconds.
- SendClientMessage(playerid, -1, "* You have spawn protection for 10 seconds.");
- }
- case 1:
- {
- AntiSKa[playerid] = 15*1000; // 15 multiplied by 1000 mili-secs = 15 seconds.
- SendClientMessage(playerid, -1, "* You have spawn protection for 15 seconds.");
- }
- case 2:
- {
- AntiSKa[playerid] = 20*1000; // 20 multiplied by 1000 mili-secs = 20 seconds.
- SendClientMessage(playerid, -1, "* You have spawn protection for 20 seconds.");
- }
- }
- AntiSK[playerid] = 1;
- AntiSKt[playerid] = SetTimerEx("AntiSKfunc", AntiSKa[playerid], false, "i", playerid);
- SendClientMessage(playerid, -1, "* Press key 'N' to end spawn protection.");
- return 1;
- }
- forward AntiSKfunc(playerid);
- public AntiSKfunc(playerid)
- {
- AntiSK[playerid] = 0;
- SetPlayerHealth(playerid, 99.0);
- SetPlayerArmour(playerid, 99.0);
- SendClientMessage(playerid, -1, "* Spawn protection ended.");
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys & KEY_NO && AntiSK[playerid] == 1)
- {
- KillTimer(AntiSKt[playerid]);
- AntiSKfunc(playerid);
- SendClientMessage(playerid, -1, "* You have ended your spawn protection.");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement