SA-MP Forums Archive
Bottle/Cigarette after respawn - 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: Bottle/Cigarette after respawn (/showthread.php?tid=624632)



Bottle/Cigarette after respawn - vassilis - 20.12.2016

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


Re: Bottle/Cigarette after respawn - Lordzy - 20.12.2016

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.