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(playeridkilleridreason)
{
                    
SendDeathMessage(killerid,playerid,reason);
                    
                    
SystemTimers[playerid][0] = SetTimerEx("SpawnPlayerAfterDeath"2000false"i"playerid);
                    return 
1;

PHP код:
function SpawnPlayerAfterDeath(playerid)
{
    if(
pinfo[playerid][Team] == NO_TEAM)
    {
                    new 
rnd random(sizeof(SpawnPoints));
                    
                    
SetSpawnInfo(playeridpinfo[playerid][Team], pinfo[playerid][Skin], SpawnPoints[rnd][0], SpawnPoints[rnd][1], SpawnPoints[rnd][2], 90.0251000000);
                    
SpawnPlayer(playerid);
                
                    
SetPlayerPos(playeridSpawnPoints[rnd][0], SpawnPoints[rnd][1], SpawnPoints[rnd][2]);
                    
ClearAnimations(playerid);
                    
KillTimer(SystemTimers[playerid][0]);
                    
SetHealth(playerid100);
                    
        
    }
    
    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: 2 Guest(s)