19.08.2012, 22:12
in this vehicle system, ( /v namecar) how to make this respawn and delete last vehicle spawned, with a timer for camera pos.. and respawn ? example please...
CMD:avehicle(playerid, params[]) { if(PlayerData[playerid][AdminLevel] < 3) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command!"); new vehicle[128], color1, color2, Float:PosX, Float:PosY, Float:PosZ, Float:Angle, model, string[128]; if(sscanf(params, "s[128]ii", vehicle, color1, color2)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /vehicle [Vehicle Name] [Color 1] [Color 2]"); GetPlayerPos(playerid, PosX, PosY, PosZ); GetPlayerFacingAngle(playerid, Angle); DestroyVehicle(AdminVehicle[playerid]); if(IsNumeric(vehicle)) { model = strval(vehicle); if(model > MAX_VEHICLE_ID || model < MIN_VEHICLE_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: The vehicle ID can't be higher than 611 or lower than 400!"); AdminVehicle[playerid] = CreateVehicle(model, PosX, PosY, PosZ, Angle, color1, color2, 120); format(string, sizeof(string), "INFO: Vehicle %s successfully spawned!", VehicleNames[model - MIN_VEHICLE_ID]); SendClientMessage(playerid, COLOR_GREEN, string); } else { model = GetVehicleModelIDFromName(vehicle); if(model == -1) return SendClientMessage(playerid, COLOR_RED, "ERROR: There was no vehicle found with this name!"); AdminVehicle[playerid] = CreateVehicle(model, PosX, PosY, PosZ, Angle, color1, color2, 120); format(string, sizeof(string), "INFO: Vehicle %s successfully spawned!", VehicleNames[model - MIN_VEHICLE_ID]); SendClientMessage(playerid, COLOR_GREEN, string); } new vid = AdminVehicle[playerid]; GetVehicleParamsEx(vid, VehicleData[vid][Engine], VehicleData[vid][Lights], VehicleData[vid][Alarm], VehicleData[vid][Doors], VehicleData[vid][Bonnet], VehicleData[vid][Boot], VehicleData[vid][Objective]); return 1; }
Код:
CMD:avehicle(playerid, params[]) { if(PlayerData[playerid][AdminLevel] < 3) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command!"); new vehicle[128], color1, color2, Float:PosX, Float:PosY, Float:PosZ, Float:Angle, model, string[128]; if(sscanf(params, "s[128]ii", vehicle, color1, color2)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /vehicle [Vehicle Name] [Color 1] [Color 2]"); GetPlayerPos(playerid, PosX, PosY, PosZ); GetPlayerFacingAngle(playerid, Angle); DestroyVehicle(AdminVehicle[playerid]); if(IsNumeric(vehicle)) { model = strval(vehicle); if(model > MAX_VEHICLE_ID || model < MIN_VEHICLE_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: The vehicle ID can't be higher than 611 or lower than 400!"); AdminVehicle[playerid] = CreateVehicle(model, PosX, PosY, PosZ, Angle, color1, color2, 120); format(string, sizeof(string), "INFO: Vehicle %s successfully spawned!", VehicleNames[model - MIN_VEHICLE_ID]); SendClientMessage(playerid, COLOR_GREEN, string); } else { model = GetVehicleModelIDFromName(vehicle); if(model == -1) return SendClientMessage(playerid, COLOR_RED, "ERROR: There was no vehicle found with this name!"); AdminVehicle[playerid] = CreateVehicle(model, PosX, PosY, PosZ, Angle, color1, color2, 120); format(string, sizeof(string), "INFO: Vehicle %s successfully spawned!", VehicleNames[model - MIN_VEHICLE_ID]); SendClientMessage(playerid, COLOR_GREEN, string); } new vid = AdminVehicle[playerid]; GetVehicleParamsEx(vid, VehicleData[vid][Engine], VehicleData[vid][Lights], VehicleData[vid][Alarm], VehicleData[vid][Doors], VehicleData[vid][Bonnet], VehicleData[vid][Boot], VehicleData[vid][Objective]); return 1; } |
new Float:x, Float:y, Float:z; TogglePlayerControllable(playerid, false); GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z); SetPlayerCameraPos(playerid, x, y, z+10); SetPlayerCameraLookAt(playerid, x, y, z); GameTextForPlayer(playerid, "Respawning...", 2000, 1); SetTimerEx("ResetCamera", 2000, false, "i", playerid); forward ResetCamera(playerid); public ResetCamera(playerid) { TogglePlayerControllable(playerid, true); SetCameraBehindPlayer(playerid); }
CMD:avehicle(playerid, params[]) { new vehicle, color1, color2, Float:PosX, Float:PosY, Float:PosZ, Float:Angle, model, string[128]; if(sscanf(params, "iii", vehicle, color1, color2)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /vehicle [Vehicle Model] [Color 1] [Color 2]"); if(model > 611 || model < 400) return SendClientMessage(playerid, COLOR_RED, "ERROR: The vehicle ID can't be higher than 611 or lower than 400!"); GetPlayerPos(playerid, PosX, PosY, PosZ); GetPlayerFacingAngle(playerid, Angle); DestroyVehicle(Vehicle[playerid]); Vehicle[playerid] = CreateVehicle(vehicle, PosX, PosY, PosZ, Angle, color1, color2, 120); PutPlayerInVehicle(playerid, Vehicle[playerid]); TogglePlayerControllable(playerid, false); GetVehiclePos(GetPlayerVehicleID(playerid), PosX, PosY, PosZ); SetPlayerCameraPos(playerid, PosX, PosY, PosZ+10); SetPlayerCameraLookAt(playerid, PosX, PosY, PosZ); GameTextForPlayer(playerid, "Respawning...", 2000, 1); SetTimerEx("ResetCamera", 2000, false, "i", playerid); return 1; } forward ResetCamera(playerid); public ResetCamera(playerid) { TogglePlayerControllable(playerid, true); SetCameraBehindPlayer(playerid); }
Код:
CMD:avehicle(playerid, params[]) { new vehicle, color1, color2, Float:PosX, Float:PosY, Float:PosZ, Float:Angle, model, string[128]; if(sscanf(params, "iii", vehicle, color1, color2)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /vehicle [Vehicle Model] [Color 1] [Color 2]"); if(model > 611 || model < 400) return SendClientMessage(playerid, COLOR_RED, "ERROR: The vehicle ID can't be higher than 611 or lower than 400!"); GetPlayerPos(playerid, PosX, PosY, PosZ); GetPlayerFacingAngle(playerid, Angle); DestroyVehicle(Vehicle[playerid]); Vehicle[playerid] = CreateVehicle(vehicle, PosX, PosY, PosZ, Angle, color1, color2, 120); PutPlayerInVehicle(playerid, Vehicle[playerid]); TogglePlayerControllable(playerid, false); GetVehiclePos(GetPlayerVehicleID(playerid), PosX, PosY, PosZ); SetPlayerCameraPos(playerid, PosX, PosY, PosZ+10); SetPlayerCameraLookAt(playerid, PosX, PosY, PosZ); GameTextForPlayer(playerid, "Respawning...", 2000, 1); SetTimerEx("ResetCamera", 2000, false, "i", playerid); return 1; } forward ResetCamera(playerid); public ResetCamera(playerid) { TogglePlayerControllable(playerid, true); SetCameraBehindPlayer(playerid); } |