01.04.2012, 15:11
Hey guys, I have an admin command to create vehicle in-game. Also I have an admin command to destroy vehicle in-game, but I want to make this command to destroy only created vehicles in-game, not vehicles in gamemode.
But the command for destroying not working. She still can destroy all vehicles including this from the gamemode.
Here are is my codes:
How to fix it?
Sorry for my bad english.
But the command for destroying not working. She still can destroy all vehicles including this from the gamemode.
Here are is my codes:
Код:
new CreatedCars[100]; new CreatedCar = 0; if(strcmp(cmd, "/veh", true) == 0) { if(PlayerInfo[playerid][pAdminLevel] >= 3) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [veh id] [color 1] [color 2]"); return 1; } new car; car = strval(tmp); if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GRAD1, "Between 400 and 61!"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [veh id] [color 1] [color 2]"); return 1; } new color1; color1 = strval(tmp); if(color1 < 0 || color1 > 255) { SendClientMessage(playerid, COLOR_GRAD1, "0 to 255!"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [veh id] [color 1] [color 2]"); return 1; } new color2; color2 = strval(tmp); if(color2 < 0 || color2 > 255) { SendClientMessage(playerid, COLOR_GRAD1, "0 to 255!"); return 1; } new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z); new carid = CreateVehicle(car, X,Y+4,Z, 0.0, color1, color2, -1); LinkVehicleToInterior(carid, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(carid, GetPlayerVirtualWorld(playerid)); VehicleFuel[carid] = 100; CreatedCars[CreatedCar] = carid; CreatedCar ++; format(string, sizeof(string), "Vehicle ID %d spawned!", carid); SendClientMessage(playerid, COLOR_WHITE, string); } else { SendClientMessage(playerid, COLOR_GRAD1, "Нямаш права за да ползваш командата!"); } return 1; } if(strcmp(cmd, "/destroycar", true)== 0) { if(PlayerInfo[playerid][pAdminLevel] >= 3) { if(IsPlayerInAnyVehicle(playerid)) { new prv = 0; for(new i = 0; i < CreatedCar; i++) { if(GetPlayerVehicleID(playerid) == CreatedCars[i]) { prv = 1; } } if(prv == 1) { return 1; } SendClientMessage(playerid, COLOR_WHITE, "Admin spawned vehicle is destroyed!"); DestroyVehicle(GetPlayerVehicleID(playerid)); } }
Sorry for my bad english.