SA-MP Forums Archive
Help with NRG spawning! - 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: Help with NRG spawning! (/showthread.php?tid=583518)



Help with NRG spawning! - Dragonic - 28.07.2015

Hi! I have this code for the spawning

Код:
    if(!strcmp(cmdtext,"/Nrg",true))
    {
    new nrg[MAX_PLAYERS];

    new Float:Pos[MAX_PLAYERS][4];
    GetPlayerPos(playerid,Pos[playerid][1],Pos[playerid][2],Pos[playerid][3]);
    nrg[playerid]=CreateVehicle(522,Pos[playerid][1],Pos[playerid][2],Pos[playerid][3],0,-1,-1,10);
    PutPlayerInVehicle(playerid,nrg[playerid], 0);
    SendClientMessage(playerid,0xFF641AFF,"You have spawned a NRG-500.");
    return 1;
    }
But the thing is that after a player leave the NRG it will stay there respawning like all the other cars! There's a way to make the nrg despawn forever after a few seconds if a player leaves it? Thanks.


AW: Help with NRG spawning! - Mencent - 28.07.2015

Hello!

PHP код:
if(!strcmp(cmdtext,"/Nrg",true))
    {
    new 
nrg[MAX_PLAYERS];
    new 
Float:Pos[MAX_PLAYERS][4];
    
GetPlayerPos(playerid,Pos[playerid][1],Pos[playerid][2],Pos[playerid][3]);
    
nrg[playerid]=CreateVehicle(522,Pos[playerid][1],Pos[playerid][2],Pos[playerid][3],0,-1,-1,-1);
    
PutPlayerInVehicle(playerid,nrg[playerid], 0);
    
SendClientMessage(playerid,0xFF641AFF,"You have spawned a NRG-500.");
    return 
1;
    } 
The 10 has to be a -1 at the end of CreateVehicle.


Re: Help with NRG spawning! - Dragonic - 28.07.2015

Still not working...


Re: Help with NRG spawning! - ChristolisTV - 29.07.2015

Just add this anywhere inside the command.
PHP код:
DestroyVehicle(nrg); 



Re: Help with NRG spawning! - liquor - 29.07.2015

https://sampwiki.blast.hk/wiki/SetTimerEx
https://sampwiki.blast.hk/wiki/DestroyVehicle


Re: Help with NRG spawning! - Dragonic - 30.07.2015

None of these work, I just can't find a way to make only the bikes spawned with /nrg despawn forever after a player leaves it...


Re: Help with NRG spawning! - IceBilizard - 30.07.2015

pawn Код:
new nrg[MAX_PLAYERS]; //Add this on top of script
Then
pawn Код:
public OnPlayerConnect(playerid)
{
      nrg[playerid] = 0;
      return 1;
}
after this

pawn Код:
if(!strcmp(cmdtext,"/Nrg",true))
    {
    new Float:Pos[MAX_PLAYERS][4];
    GetPlayerPos(playerid,Pos[playerid][1],Pos[playerid][2],Pos[playerid][3]);
    nrg[playerid]=CreateVehicle(522,Pos[playerid][1],Pos[playerid][2],Pos[playerid][3],0,-1,-1,-1);
    PutPlayerInVehicle(playerid,nrg[playerid], 0);
    SendClientMessage(playerid,0xFF641AFF,"You have spawned a NRG-500.");
    return 1;
    }
then if you want to destroy when player leave the nrg do this

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
          if(nrg[playerid] != 0)
         {
               DestroyVehicle(nrg[playerid]);
         }
          return 1;
}



Re: Help with NRG spawning! - Dragonic - 30.07.2015

Thanks IceBilizard, I'll test it when I get home later to see if it works (: