// Lights new Light[MAX_VEHICLES]; new LightObject[MAX_VEHICLES]; CMD:light(playerid, params[]) { new veh, type[8], string[128]; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle."); if(sscanf(params, "s[8]", type)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /light [position]"); SendClientMessage(playerid, COLOR_WHITE, "POSITIONS: on|off"); return 1; } if(Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "This vehicle already has a Light attached."); veh = GetPlayerVehicleID(playerid); if(!strcmp(type, "on")) { if(Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a light attached to this vehicle."); Light[veh] = 1; LightObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0); AttachDynamicObjectToVehicle(LightObject[veh],veh, x, y, z, 0.0, 0.1, 0.0); format(string, sizeof(string), "* %s attaches a light to the car.", RPN(playerid)); SendNearbyMessage(playerid, 15, string, Colors); return 1; else if(!strcmp(type, "off")) { if(!Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is no Lights attached to this vehicle."); Light[veh] = 0; DestroyDynamicObject(LightObject[veh]); format(string, sizeof(string), "* %s takes the Light off the car.", RPN(playerid)); SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE); return 1; } return 1; }
My exampel
Код:
// Lights new Light[MAX_VEHICLES]; new LightObject[MAX_VEHICLES]; CMD:light(playerid, params[]) { new veh, type[8], string[128]; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle."); if(sscanf(params, "s[8]", type)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /light [position]"); SendClientMessage(playerid, COLOR_WHITE, "POSITIONS: on|off"); return 1; } if(Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "This vehicle already has a Light attached."); veh = GetPlayerVehicleID(playerid); if(!strcmp(type, "on")) { if(Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a light attached to this vehicle."); Light[veh] = 1; LightObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0); AttachDynamicObjectToVehicle(LightObject[veh],veh, x, y, z, 0.0, 0.1, 0.0); format(string, sizeof(string), "* %s attaches a light to the car.", RPN(playerid)); SendNearbyMessage(playerid, 15, string, Colors); return 1; else if(!strcmp(type, "off")) { if(!Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is no Lights attached to this vehicle."); Light[veh] = 0; DestroyDynamicObject(LightObject[veh]); format(string, sizeof(string), "* %s takes the Light off the car.", RPN(playerid)); SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE); return 1; } return 1; } |
new vehid = GetPlayerVehicleID(playerid); if(DFT(vehid)) { |