nrg/spawn command
#1

Someone can give me a samp nrg/inferno spawn command, with destroy? I make one but it's a little bugged.. this is my command:
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
new 
Float:Pos[3],inf[MAX_PLAYERS],nrg[MAX_PLAYERS];
if(!
strcmp(cmdtext,"/inf",true))
{
    if(
inf[playerid] == 0)
    {
        
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
        
inf[playerid] = CreateVehicle(411,Pos[0],Pos[1],Pos[2],0,-1,-1,10);
        
PutPlayerInVehicle(playerid,inf[playerid],0);
        
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned An Infernus.");
        return 
1;
    }
    else if(
inf[playerid] > 0)
    {
        
DestroyVehicle(inf[playerid]);
        
inf[playerid] = 0;
    }
    return 
1;
}
if(!
strcmp(cmdtext,"/nrg",true))
{
    if(
nrg[playerid] == 0)
    {
        
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
        
nrg[playerid] = CreateVehicle(522,Pos[0],Pos[1],Pos[2],0,-1,-1,10);
        
PutPlayerInVehicle(playerid,nrg[playerid],0);
        
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned A NRG-500.");
        return 
1;
    }
    else if(
nrg[playerid] > 0)
    {
        
DestroyVehicle(nrg[playerid]);
        
nrg[playerid] = 0;
    }
    return 
1;
}
 return 
0;

Reply
#2

First, I recommend u use dcmd, by adding this line to the top of your script
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
or use ZCMD, search it.

Second, when you post a help post, post the errors you get, so.. what are the errors?
Reply
#3

Hi!

I am the person who wrote you the code. I told you that you should put the declaration above OnGameModeInit:
PHP код:
//global (above OnGameModeInit):
new Float:Pos[3],inf[MAX_PLAYERS],nrg[MAX_PLAYERS];
//the public:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(!
strcmp(cmdtext,"/inf",true))
    {
        if(
inf[playerid] == 0)
        {
            
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
            
inf[playerid] = CreateVehicle(411,Pos[0],Pos[1],Pos[2],0,-1,-1,10);
            
PutPlayerInVehicle(playerid,inf[playerid],0);
            
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned An Infernus.");
            return 
1;
        }
        else if(
inf[playerid] > 0)
        {
            
DestroyVehicle(inf[playerid]);
            
inf[playerid] = 0;
        }
        return 
1;
    }
    if(!
strcmp(cmdtext,"/nrg",true))
    {
        if(
nrg[playerid] == 0)
        {
            
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
            
nrg[playerid] = CreateVehicle(522,Pos[0],Pos[1],Pos[2],0,-1,-1,10);
            
PutPlayerInVehicle(playerid,nrg[playerid],0);
            
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned A NRG-500.");
            return 
1;
        }
        else if(
nrg[playerid] > 0)
        {
            
DestroyVehicle(nrg[playerid]);
            
nrg[playerid] = 0;
        }
        return 
1;
    }
     return 
0;

Reply
#4

Quote:
Originally Posted by Vanter
Посмотреть сообщение
First, I recommend u use dcmd, by adding this line to the top of your script
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
or use ZCMD, search it.

Second, when you post a help post, post the errors you get, so.. what are the errors?
It's not any error, when i use the command the previos car dosen't destroy, and i don't know how to do it...
Reply
#5

Use my code above your last post.
Reply
#6

PHP код:
new
    
infernus[MAX_PLAYERS],
    
nrg[MAX_PLAYERS];

public 
OnPlayerCommandText(playeridcmdtext[])
{
    if(!
strcmp(cmdtext,"/inf",true))
    {
        if(
infernus[playerid] == 0)
        {
            static
                
Float:pos[3];
                
            
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
            
infernus[playerid] = CreateVehicle(411pos[0], pos[1], pos[2], 0, -1, -110);
            
infernus[playerid]++; // If the vehicle is ID "0", he can't destroy him, so I fix this bug with incrementation of the variable.
            
            
PutPlayerInVehicle(playeridinfernus[playerid]-10);
            
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned An Infernus.");
            return 
1;
        }
        else
        {
            
DestroyVehicle(infernus[playerid]-1);
            
infernus[playerid] = 0;
        }
        return 
1;
    }
    if(!
strcmp(cmdtext"/nrg"true))
    {
        if(
nrg[playerid] == 0)
        {
            static
                
Float:pos[3];
                
            
GetPlayerPos(playeridpos[0], pos[1], pos[2]);
            
nrg[playerid] = CreateVehicle(522pos[0], pos[1], pos[2], 0, -1, -110);
            
nrg[playerid]++; // If the vehicle is ID "0", he can't destroy him, so I fix this bug with incrementation of the variable.
            
            
PutPlayerInVehicle(playeridnrg[playerid]-10);
            
SendClientMessage(playerid0xFF641AFF"SERVER: You have Spawned A NRG-500.");
            return 
1;
        }
        else if(
nrg[playerid] > 0)
        {
            
DestroyVehicle(nrg[playerid]-1);
            
nrg[playerid] = 0;
        }
        return 
1;
    }
    return 
0;

Reply
#7

Hi, the code work, but i need to use the command 2 times to destroy and spawn another one... can you give me something else ? let's say when i use the command to destroy previos vehicle and spawn aanother one
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)