spawn car/nrg with a command -
MonSterLikeHD - 27.03.2016
Hi, one of my friend give me this script for a nrg/inf car spawner, this is the script:
{
new Float:Pos[4],inf;
new Float:Pose[4],nrg;
if(!strcmp(cmdtext,"/inf",true))
{
GetPlayerPos(playerid,Pos[1],Pos[2],Pos[3]);
inf=CreateVehicle(411,Pos[1],Pos[2],Pos[3],0,-1,-1,10);
PutPlayerInVehicle(playerid,inf, 0);
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned An Infernus.");
return 1;
}
if(!strcmp(cmdtext,"/nrg",true))
{
GetPlayerPos(playerid,Pose[1],Pose[2],Pose[3]);
nrg=CreateVehicle(522,Pose[1],Pose[2],Pose[3],0,-1,-1,10);
PutPlayerInVehicle(playerid,nrg, 0);
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned An NRG-500.");
return 1;
}
return 0;
}
But i have a problem, when i use this command again, the car didn't destroy, someone can help me ?
Re: spawn car/nrg with a command -
Mencent - 27.03.2016
Hi!
Do it like this. I think you can see what I changed, can't you?
PHP код:
new Float:Pos[2][4],inf[MAX_PLAYERS],nrg[MAX_PLAYERS];
if(!strcmp(cmdtext,"/inf",true))
{
if(inf[playerid] == 0)
{
GetPlayerPos(playerid,Pos[0][0],Pos[0][1],Pos[0][2]);
inf[playerid] = CreateVehicle(411,Pos[0][0],Pos[0][1],Pos[0][2],0,-1,-1,10);
PutPlayerInVehicle(playerid,inf[playerid],0);
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned An Infernus.");
return 1;
}
else
{
DestroyVehicle(inf[playerid]);
inf[playerid] = 0;
}
return 1;
}
if(!strcmp(cmdtext,"/nrg",true))
{
if(nrg[playerid] == 0)
{
GetPlayerPos(playerid,Pos[0][0],Pos[0][1],Pos[0][2]);
nrg[playerid] = CreateVehicle(522,Pos[0][0],Pos[0][1],Pos[0][2],0,-1,-1,10);
PutPlayerInVehicle(playerid,nrg[playerid],0);
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned A NRG-500.");
return 1;
}
else
{
DestroyVehicle(nrg[playerid]);
nrg[playerid] = 0;
}
return 1;
}
Re: spawn car/nrg with a command -
MonSterLikeHD - 27.03.2016
Dude it works, when i am in the car and i use the command again, but when i am outside the car, and i use the command again, dosen't work, the previosly car dosen't destroy
Re: spawn car/nrg with a command -
Mencent - 27.03.2016
What will happen when you write it like this?
PHP код:
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;
}
Re: spawn car/nrg with a command -
MonSterLikeHD - 27.03.2016
D:\Samp Roleplay Server Beta Testing\gamemodes\CP.pwn(96) : error 028: invalid subscript (not an array or too many subscripts): "inf"
D:\Samp Roleplay Server Beta Testing\gamemodes\CP.pwn(96) : warning 215: expression has no effect
D:\Samp Roleplay Server Beta Testing\gamemodes\CP.pwn(96) : error 001: expected token: ";", but found "]"
D:\Samp Roleplay Server Beta Testing\gamemodes\CP.pwn(96) : error 029: invalid expression, assumed zero
D:\Samp Roleplay Server Beta Testing\gamemodes\CP.pwn(96) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.