Help with NRG spawning!
#1

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

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

Still not working...
Reply
#4

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

https://sampwiki.blast.hk/wiki/SetTimerEx
https://sampwiki.blast.hk/wiki/DestroyVehicle
Reply
#6

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

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;
}
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)