Spawnkill help! - 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: Spawnkill help! (
/showthread.php?tid=608376)
Spawnkill help! -
Fantje - 31.05.2016
I made an anti-spawnkill,
but the problem is:
I can't kill people but they can kill me.
The anti-spawnkill also only works on me.
here the codes:
PHP код:
forward spawnkill(playerid);
public spawnkill(playerid)
{
new Text3D:label;
SetPlayerHealth(playerid, 100.0);
SendClientMessage(playerid, COLOR_RED, "Spawn protection is over. You are ready to combat.");
Delete3DTextLabel(label);
}
public OnPlayerSpawn(playerid)
{
/* Spawn Protection*/
new Text3D:label = Create3DTextLabel("Spawn protection", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
SetPlayerHealth(playerid, 99999);
SetTimer("spawnkill", 10000, false);
return 1;
}
Whats wrong?
Please help
Re: Spawnkill help! -
Sjn - 31.05.2016
You are using SetTimer function instead of SetTimerEx. You need to assign the playerid parameter in order for the timer to work for the selected player only.
Also, if you are not using SetPlayerChatBubble function anywhere, I'd recommend you to use it instead of 3D text label.
Something like;
PHP код:
forward AntiSpawnKill(playerid);
public AntiSpawnKill(playerid)
{
SetPlayerHealth(playerid, 100.0);
SendClientMessage(playerid, COLOR_RED, "Spawn protection is over. You are ready to combat.");
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 99999.99);
SendClientMessage(playerid, -1, "Anti spawn kill protected for 10 seconds.");
SetPlayerChatBubble(playerid, "Spawn Kill Protected", COLOR_RED, 10.0, 10000);
SetTimerEx("AntiSpawnKill", 10000, false, "i", playerid);
return 1;
}
Re: Spawnkill help! -
Dayrion - 31.05.2016
This is wrong
PHP код:
SetTimer("spawnkill", 10000, false);
Replace
PHP код:
SetTimerEx("spawnkill", 10000, false, "i", playerid);
EDIT: Sjn was faster.
Re: Spawnkill help! -
Fantje - 31.05.2016
Thank you for explaining!