02.04.2016, 11:04
Hi, someone give me this code:
My problem is, i need to type the command 2 times to destroy the vehicle, but i want to use only one time
PHP код:
new
infernus[MAX_PLAYERS],
nrg[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext,"/inf",true))
{
if(infernus[playerid] == 0)
{
static
Float:pos[3];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
infernus[playerid] = CreateVehicle(411, pos[0], pos[1], pos[2], 0, -1, -1, 10);
infernus[playerid]++; // If the vehicle is ID "0", he can't destroy him, so I fix this bug with incrementation of the variable.
PutPlayerInVehicle(playerid, infernus[playerid]-1, 0);
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(playerid, pos[0], pos[1], pos[2]);
nrg[playerid] = CreateVehicle(522, pos[0], pos[1], pos[2], 0, -1, -1, 10);
nrg[playerid]++; // If the vehicle is ID "0", he can't destroy him, so I fix this bug with incrementation of the variable.
PutPlayerInVehicle(playerid, nrg[playerid]-1, 0);
SendClientMessage(playerid, 0xFF641AFF, "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;
}