Loop problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Loop problem (
/showthread.php?tid=484974)
Loop problem -
Lidor124 - 02.01.2014
Hey again :d
I'm sure you know the command /veh and /destroycar(s)
Then my problem is when i use the command /veh to spawn a vehicle and it is owns by None its working perfect and it creates the veh on my position etc.
But when i use the command /destroycars its destroy all the vehicles i have spawned by /veh but the problem is -
when i use the command /veh again the vehicle wasn't spawned.
So i think the problem is on the loop of /destroycars, it deletes all the vehicles but then the next car by command /veh it won't spawn... then here the codes and help me out please:
/destroycars command:
Код:
CMD:destroycars(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
new string[103];
for(new i = 0; i < sizeof(cVeh); i++)
{
if(cVeh[i] == INVALID_VEHICLE_ID) continue;
DestroyVehicle(cVeh[i]);
cVeh[i] = -1;
}
format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has destroyed all Created vehicles (/veh)icle.", NORPN(playerid));
SendAdminMessage(COLOR_DARKRED, 1, string);
SendClientMessage(playerid, COLOR_GREY, "(/veh)icle Created vehicles destroyed!");
return 1;
}
/veh command
Код:
CMD:veh(playerid, params[])
{
new id, Float:pos[4], col[2], stringlog[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
// if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
if(sscanf(params, "iii", id, col[0], col[1])) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [model ID] [color 1] [color 2]");
if(id < 400 || id > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
{
if(!cVeh[i])
{
cVeh[i] = CreateVehicle(id, pos[0], pos[1], pos[2], pos[3], col[0], col[1], 12000);
LinkVehicleToInterior(cVeh[i], GetPlayerInterior(playerid));
i = MAX_CUSTOM_VEHICLES;
}
}
new string[128];
format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has spawned a (/veh)icle model %d.", NORPN(playerid), id);
SendAdminMessage(COLOR_DARKRED, 1, string);
// veh Log
Log("logs/veh.log", stringlog);
return 1;
}