Anti-SpawnKill Tag issue
#1

Hey guys, I'm having a problem, with the Anti-Spawnkill tag, the problem is that it works fine but the problem or issue is that when the player Spawn's, the Tag is displayed and the player's health is blinking, but even after the Timer runs out for the Anti-Spawnkill, 5 seconds, the ridiculous Tag is not destroyed. Below I'll post the code:

Код:
new Text3D:antispawnkill;
Код:
public OnPlayerSpawn(playerid)
{
	SetPlayerHealth(playerid, 99999.0);
	SetPlayerVirtualWorld(playerid, 0);
    SendClientMessage(playerid, 0xFF0000AA, "You can't be killed for 5 second(s) (spawn protection)");
    SetPlayerWantedLevel(playerid, 0);
    SetTimerEx("AntiSpawnkill",PROTECTIONTIME*1500,0,"d",playerid);
    antispawnkill = Create3DTextLabel("Anti-Spawnkill Protected", 0xFF0000FF , 30.0, 40.0, 50.0, 40.0, 0); //SPAWNKILLTAG
    Attach3DTextLabelToPlayer(antispawnkill, playerid, 0.0, 0.0, 0.7);
Код:
public AntiSpawnkill(playerid)
{
    DeletePlayer3DTextLabel(playerid, PlayerText3D:antispawnkill);   //SpawnKill TAG
    SetPlayerHealth(playerid, 100.0);
    SendClientMessage(playerid, 0x00ff00ff, "Anti Spawn kill protection over.");
    return 1;
}
So what's the problem, can anyone help out in this mess?
Reply
#2

In your time put False
This bug is of the time and usually happens when ta in True has to be false.
Reply
#3

You mean like this?

Код:
SetTimerEx("AntiSpawnkill",PROTECTIONTIME*1500, false,"d",playerid);
Reply
#4

You need an array to store the labelids otherwise you won't be able to destroy them.
Reply
#5

Yes, I did a spawn kill and it's giving you the same error yours, I put it false and it worked
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
You need an array to store the labelids otherwise you won't be able to destroy them.
Hey Vince, long time no see. Anyway man, can you elaborate? Label ID's?
Reply
#7

Quote:
Originally Posted by Sting.
Посмотреть сообщение
Hey Vince, long time no see. Anyway man, can you elaborate? Label ID's?
You must store the IDs of every player's 3DTextLabel (this is returned by Create3DTextLabel), you're currently storing only one ID and destroying that ID regardless. Also, destroy the old 3DTextLabel when the player spawns to avoid any overlapping.

PHP код:
new Text3D:antispawnkill
should be
PHP код:
new Text3D:antispawnkill[MAX_PLAYERS]; 
and I guess you know what to do next
Reply
#8

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerHealth(playerid, 99999.0);
    SetPlayerVirtualWorld(playerid, 0);
    SendClientMessage(playerid, 0xFF0000AA, "You can't be killed for 5 second(s) (spawn protection)");
    SetPlayerWantedLevel(playerid, 0);
    antispawnkill = Create3DTextLabel("Anti-Spawnkill Protected", 0xFF0000FF , 30.0, 40.0, 50.0, 40.0, 0); //SPAWNKILLTAG
    Attach3DTextLabelToPlayer(antispawnkill, playerid, 0.0, 0.0, 0.7);
    SetTimerEx("AntiSpawnkill",PROTECTIONTIME*1500,0,"ii",playerid,_:antispawnkill);


public AntiSpawnkill(playerid, labelid)
{
    Delete3DTextLabel(Text3D:labelid);  //SpawnKill TAG
    SetPlayerHealth(playerid, 100.0);
    SendClientMessage(playerid, 0x00ff00ff, "Anti Spawn kill protection over.");
    return 1;
}
Reply
#9

Код:
public AntiSpawnkill(playerid, labelid)
I get an error.

Код:
error 025: function heading differs from prototype
Reply
#10

Код:
forward AntiSpawnkill(playerid, labelid);
Reply
#11

Compiled it and got no errors, will check it though tomorrow with a friend to see whether it works.
Reply
#12

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;

Reply
#13

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

Code:
error 017: undefined symbol "MAX_PLAYERS"
error 025: function heading differs from prototype
Reply
#14

Download the server package and replace your includes with the ones found in said package.
Reply
#15

@Sting. just use jefff code its the best method around here.
Reply
#16

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.
Reply
#17

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;

Reply
#18

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)