25.04.2010, 19:17
How to delete the cars made by the command /v
Код:
public OnPlayerCommandText(playerid, cmdtext[]) { // DCMD DEFINE's dcmd(help,4,cmdtext); dcmd(s,1,cmdtext); // 1 = amount of character dcmd(skin,4,cmdtext); new cmd[256], tmp[256], idx; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/v", true, 3) == 0) { new String[200]; new Float:x, Float:y, Float:z,Float:a; GetPlayerFacingAngle(playerid, a); GetPlayerPos(playerid, x, y, z); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE:/v <Vehicle NAME|ID>"); new vehicle = GetVehicleModelIDFromName(tmp); if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid,COLOR_RED, "ERROR: Invalid vehicle NAME/ID"); if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid, COLOR_RED, "[VEHICLE]: You are already in a vehicle."); return 1; } else { GetXYInFrontOfPlayer(playerid, x, y, 1); } new Vid = AddStaticVehicleEx(vehicle,x, y,z, a, -1, -1, -1); PutPlayerInVehicle(playerid,Vid,0); LinkVehicleToInterior(Vid, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(Vid,GetPlayerVirtualWorld(playerid)); format(String, sizeof(String), "%s has spawned a %s (ID:%i - MODEL ID: %i)", GetPName(playerid),aVehicleNames[vehicle - 400],Vid, vehicle); SendClientMessageToAll(COLOR_RED, String); return 1; } return 0; }
Код:
if(strcmp(cmdtext, "/dv", true) == 0) { new Vid; Vid = GetPlayerVehicleID(playerid); DestroyVehicle(Vid); return 1; }