19.12.2012, 22:22
Okay, so the problem with this command is that when people use the command twice (once to spawn their car, and the other for the hell of it) it keeps spawning their cars. So if they use it 3 times, it spawns 3 cars.
What I need help on is basically making a function of some sort (or whatever it's called) that checks if a certain player already has their car spawned (either 1 or 2) to send them a message saying "you already have a car spawned!" and not letting them create a new car.
What I need help on is basically making a function of some sort (or whatever it's called) that checks if a certain player already has their car spawned (either 1 or 2) to send them a message saying "you already have a car spawned!" and not letting them create a new car.
pawn Код:
CMD:getcar(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
new num;
if(sscanf(params, "d", num)) return SendClientMessage(playerid, -1, "USAGE: /getcar [1-2]");
if(num != 1 && num != 2) return SendClientMessage(playerid, -1, "USAGE: /getcar [1-2]");
if(num == 1)
{
if(PlayerInfo[playerid][vModel])
{
PlayerInfo[playerid][pVeh] = CreateVehicle(PlayerInfo[playerid][vModel], PlayerInfo[playerid][vX],PlayerInfo[playerid][vY],PlayerInfo[playerid][vZ],PlayerInfo[playerid][vA],PlayerInfo[playerid][vC1],PlayerInfo[playerid][vC2],1200);
if(PlayerInfo[playerid][vLocked]) SetVehicleParamsEx(PlayerInfo[playerid][pVeh], 0, 0, 0, 0, 0, 0, 0);
for(new i=0; i<14; i++)
{
AddVehicleComponent(PlayerInfo[playerid][pVeh], PlayerInfo[playerid][pVehMod][i]);
}
SendClientMessage(playerid, COLOR_GREY, "Your vehicle has been spawned.");
}
return 1;
}
else if(num == 2)
{
if(PlayerInfo[playerid][vVModel])
{
PlayerInfo[playerid][pVVeh] = CreateVehicle(PlayerInfo[playerid][vVModel], PlayerInfo[playerid][vVX],PlayerInfo[playerid][vVY],PlayerInfo[playerid][vVZ],PlayerInfo[playerid][vVA],PlayerInfo[playerid][vVC1],PlayerInfo[playerid][vVC2],1200);
if(PlayerInfo[playerid][vVLocked]) SetVehicleParamsEx(PlayerInfo[playerid][pVVeh], 0, 0, 0, 0, 0, 0, 0);
for(new i=0; i<14; i++)
{
AddVehicleComponent(PlayerInfo[playerid][pVVeh], PlayerInfo[playerid][pVVehMod][i]);
}
SendClientMessage(playerid, COLOR_GREY, "Your vehicle has been spawned.");
}
return 1;
}
return 1;
}