Bottle/Cigarette after respawn
#1

I tried everything but yet didnt seem to work.. I even search on old similar posts but didn't find a quite answer..
After i die it spawns my player with a bottle in his hands or a cigarette..
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
                    
SendDeathMessage(killerid,playerid,reason);
                    
                    
SystemTimers[playerid][0] = SetTimerEx("SpawnPlayerAfterDeath", 2000, false, "i", playerid);
                    return 
1;
} 
PHP код:
function SpawnPlayerAfterDeath(playerid)
{
    if(
pinfo[playerid][Team] == NO_TEAM)
    {
                    new 
rnd = random(sizeof(SpawnPoints));
                    
                    
SetSpawnInfo(playerid, pinfo[playerid][Team], pinfo[playerid][Skin], SpawnPoints[rnd][0], SpawnPoints[rnd][1], SpawnPoints[rnd][2], 90.0, 25, 100, 0, 0, 0, 0);
                    
SpawnPlayer(playerid);
                
                    
SetPlayerPos(playerid, SpawnPoints[rnd][0], SpawnPoints[rnd][1], SpawnPoints[rnd][2]);
                    
ClearAnimations(playerid);
                    
KillTimer(SystemTimers[playerid][0]);
                    
SetHealth(playerid, 100);
                    
        
    }
    
    return 
true;
} 
P.S: It spawns correctly and after 2 seconds it re-spawns with bottle/cigarette..
Reply
#2

It's mostly because the player is already attempting to spawn after death, so calling out for a separate spawn is unnecessary. You can set the spawn info under OnPlayerDeath and the rest under OnPlayerSpawn - where the player spawns after death. Here in your case, the SpawnPlayer function is called twice together which is why you end up with a cigar.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)