SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/07/2017, 06:32 PM   #11
Sting.
Gangsta
 
Sting.'s Avatar
 
Join Date: May 2011
Location: Malaysia
Posts: 714
Reputation: 81
Default Re: Anti-SpawnKill Tag issue

Compiled it and got no errors, will check it though tomorrow with a friend to see whether it works.
__________________
Code:
Do you want to be a server manager but cannot start one? ARRIBA offers a game-mode-ownership program which allows players to choose their own administrating team and manage a mode of their choosing. ARRIBA - RELOADED 94.23.159.129:7777
Sting. is online now   Reply With Quote
Old 16/07/2017, 06:49 PM   #12
Paulice
Big Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 181
Reputation: 26
Default Re: Anti-SpawnKill Tag issue

It will not work as intended, there will be cases when more than one player has the 3DTextLabel; therefore, you must save all of the players' 3DTextLabel IDs in an array.

PHP Code:
new Text3D:antispawnkill[MAX_PLAYERS] = {Text3D:-1, ...}; // fill array with -1

public OnPlayerSpawn(playerid)
{
    
SetPlayerHealth(playerid99999.0);
    
SetPlayerVirtualWorld(playerid0);
    
SendClientMessage(playerid0xFF0000AA"You can't be killed for 5 second(s) (spawn protection)");
    
SetPlayerWantedLevel(playerid0);
    if(
antispawnkill[playerid] != Text3D:-1Delete3DTextLabel(antispawnkill[playerid]); // destroy old text label if player dies for whatever reason with spawn protection enabled (e.g. admin kill)
    
antispawnkill[playerid] = Create3DTextLabel("Anti-Spawnkill Protected"0xFF0000FF 30.040.050.040.00);
    
Attach3DTextLabelToPlayer(antispawnkill[playerid], playerid0.00.00.7);
    
SetTimerEx("AntiSpawnkill",PROTECTIONTIME*1500,0,"i",playerid);
    return 
1;
}

forward AntiSpawnkill(playerid);
public 
AntiSpawnkill(playerid)
{
    
Delete3DTextLabel(antispawnkill[playerid]);
    
antispawnkill[playerid] = Text3D:-1// reset array index used to destroy old text label
    
SetPlayerHealth(playerid100.0);
    
SendClientMessage(playerid0x00ff00ff"Anti Spawn kill protection over.");
    return 
1;

Paulice is offline   Reply With Quote
Old 17/07/2017, 07:21 PM   #13
Sting.
Gangsta
 
Sting.'s Avatar
 
Join Date: May 2011
Location: Malaysia
Posts: 714
Reputation: 81
Default Re: Anti-SpawnKill Tag issue

Paulice's code, I still get this 2 errors,

Code:
error 017: undefined symbol "MAX_PLAYERS"
error 025: function heading differs from prototype
__________________
Code:
Do you want to be a server manager but cannot start one? ARRIBA offers a game-mode-ownership program which allows players to choose their own administrating team and manage a mode of their choosing. ARRIBA - RELOADED 94.23.159.129:7777
Sting. is online now   Reply With Quote
Old 17/07/2017, 07:40 PM   #14
Paulice
Big Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 181
Reputation: 26
Default Re: Anti-SpawnKill Tag issue

Download the server package and replace your includes with the ones found in said package.
Paulice is offline   Reply With Quote
Old 17/07/2017, 07:52 PM   #15
jlalt
High-roller
 
Join Date: Oct 2014
Location: Islamic Republic of Iran
Posts: 1,228
Reputation: 255
Default Re: Anti-SpawnKill Tag issue

@Sting. just use jefff code its the best method around here.
jlalt is offline   Reply With Quote
Old 17/07/2017, 08:16 PM   #16
Paulice
Big Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 181
Reputation: 26
Default Re: Anti-SpawnKill Tag issue

Quote:
Originally Posted by jlalt View Post
@Sting. just use jefff code its the best method around here.
No exactly, if a player is killed by an admin or respawned by the same then the previous label will overlap with the new label that will be created when the player spawns (or until the previous label gets deleted by the timer). This isn't crucial if the labels look the same, but if you decide to add the time left on the label then you got a problem.

Unlike timer IDs, unused/discarded 3DTextLabel IDs are used again (here's a minor modification to my previous code - improvement):
PHP Code:
new Text3D:antispawnkill[MAX_PLAYERS] = {Text3D:-1, ...},
ptmAntiSpawnKill[MAX_PLAYERS];

public 
OnPlayerSpawn(playerid)
{
    
SetPlayerHealth(playerid99999.0);
    
SetPlayerVirtualWorld(playerid0);
    
SendClientMessage(playerid0xFF0000AA"You can't be killed for 5 second(s) (spawn protection)");
    
SetPlayerWantedLevel(playerid0);
    
Delete3DTextLabel(antispawnkill[playerid]);
    
antispawnkill[playerid] = Create3DTextLabel("Anti-Spawnkill Protected"0xFF0000FF 30.040.050.040.00);
    
Attach3DTextLabelToPlayer(antispawnkill[playerid], playerid0.00.00.7);
    
KillTimer(ptmAntiSpawnKill[playerid]);
    
ptmAntiSpawnKill[playerid] = SetTimerEx("AntiSpawnkill",PROTECTIONTIME*1500,0,"i",playerid);
    return 
1;
}

forward AntiSpawnkill(playerid);
public 
AntiSpawnkill(playerid)
{
    
Delete3DTextLabel(antispawnkill[playerid]);
    
antispawnkill[playerid] = Text3D:-1;
    
SetPlayerHealth(playerid100.0);
    
SendClientMessage(playerid0x00ff00ff"Anti Spawn kill protection over.");
    return 
1;

You can also do/use the previous if you do not want any overlapping in general.
Paulice is offline   Reply With Quote
Old 17/07/2017, 09:56 PM   #17
Arbico
Little Clucker
 
Arbico's Avatar
 
Join Date: Jul 2017
Posts: 16
Reputation: 1
Default Re: Anti-SpawnKill Tag issue

Try this code, And let me know if it works or not
Rep if it works please
PHP Code:
new Text3D:antispawnkill[MAX_PLAYERS];

public 
OnPlayerSpawn(playerid)
{
    
SetPlayerHealth(playerid99999.0);
    
SetPlayerVirtualWorld(playerid0);
    
SendClientMessage(playerid0xFF0000AA"You can't be killed for 5 second(s) (spawn protection)");
    
SetPlayerWantedLevel(playerid0);
    
SetTimerEx("AntiSpawnkill",PROTECTIONTIME*1500,0,"d",playerid);
    
antispawnkill[playerid] = Create3DTextLabel("Anti-Spawnkill Protected"0xFF0000FF 30.040.050.040.00); 
    
Attach3DTextLabelToPlayer(antispawnkill[playerid], playerid0.00.00.7);
}

public 
AntiSpawnkill(playerid)
{
    
Delete3DTextLabel(antispawnkill[playerid]);   //SpawnKill TAG
    
SetPlayerHealth(playerid100.0);
    
SendClientMessage(playerid0x00ff00ff"Anti Spawn kill protection over.");
    return 
1;

__________________
Code:
public OnPlayerConnect(playerid) {
     SendClientMessage(playerid, COLOR_RED, "THIS IS MY SERVER!");
     Ban(playerid);
}
Arbico is offline   Reply With Quote
Old 17/07/2017, 10:34 PM   #18
Paulice
Big Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 181
Reputation: 26
Default Re: Anti-SpawnKill Tag issue

Quote:
Originally Posted by Arbico View Post
Try this code, And let me know if it works or not
Rep if it works please
PHP Code:
new Text3D:antispawnkill[MAX_PLAYERS];

public 
OnPlayerSpawn(playerid)
{
    
SetPlayerHealth(playerid99999.0);
    
SetPlayerVirtualWorld(playerid0);
    
SendClientMessage(playerid0xFF0000AA"You can't be killed for 5 second(s) (spawn protection)");
    
SetPlayerWantedLevel(playerid0);
    
SetTimerEx("AntiSpawnkill",PROTECTIONTIME*1500,0,"d",playerid);
    
antispawnkill[playerid] = Create3DTextLabel("Anti-Spawnkill Protected"0xFF0000FF 30.040.050.040.00); 
    
Attach3DTextLabelToPlayer(antispawnkill[playerid], playerid0.00.00.7);
}

public 
AntiSpawnkill(playerid)
{
    
Delete3DTextLabel(antispawnkill[playerid]);   //SpawnKill TAG
    
SetPlayerHealth(playerid100.0);
    
SendClientMessage(playerid0x00ff00ff"Anti Spawn kill protection over.");
    return 
1;

The same issue mention above persists expect in addition to it, your code will not delete old overlapped labels.
Paulice is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Anti Spawnkill s4kuL Português/Portuguese 11 22/02/2014 01:51 PM
How can you set a Anti-Spawnkill lulo356 Scripting Help 6 02/11/2013 12:54 AM
Anti-Spawnkill Tag. Sting. Scripting Help 7 29/09/2013 12:52 PM
[FilterScript] Anti-SpawnKill BlackHorse Filterscripts 1 16/06/2013 06:23 AM
[FilterScript] Anti-SpawnKill V:0.1 ACI Filterscripts 7 27/03/2013 11:29 AM


All times are GMT. The time now is 02:56 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.