public OnPlayerCommandText(playerid, cmdtext[])
{
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;
}
#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
//global (above OnGameModeInit):
new Float:Pos[3],inf[MAX_PLAYERS],nrg[MAX_PLAYERS];
//the public:
public OnPlayerCommandText(playerid, cmdtext[])
{
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;
}
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 Second, when you post a help post, post the errors you get, so.. what are the errors? |
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;
}