15.05.2018, 20:37
I want to make a system in my server that when you are in range of predefined point and use a cmd /fixcar something like this should pop up
cmd:test(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid, 10.0, xxxxx, yyyyyy, zzzz) return SendClientMessage(playerid, color_red, "you are not near the point!");
ShowPlayerDialog(playerid, 4520, DIALOG_STYLE_LIST, "Select an option", "Engine\nBodyWork\n");
return 1;
}
#include <a_samp> #define FILTERSCRIPT #if defined FILTERSCRIPT //colors #define COLOR_RED 0xAA3333AA #define COLOR_WHITE 0xFFFFFFAA //dialogs #define DIALOG_TYPE_MAIN 144 /* Encodes */ encode_tires(tire1, tire2, tire3, tire4) return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3); encode_panels(flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper) { return flp | (frp << 4) | (rlp << 8) | (rrp << 12) | (windshield << 16) | (front_bumper << 20) | (rear_bumper << 24); } encode_doors(bonnet, boot, driver_door, passenger_door, behind_driver_door, behind_passenger_door) { #pragma unused behind_driver_door #pragma unused behind_passenger_door return bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24); } encode_lights(light1, light2, light3, light4) { return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3); } //menus static pvehicleid[MAX_PLAYERS]; // array containing players vehicle id (loaded when player enters as driver) static pmodelid[MAX_PLAYERS]; // array containing players vehicle MODEL id (loaded when player enters as driver) public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Car repair shop"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } #else main() { } #endif public OnPlayerConnect(playerid) { pvehicleid[playerid] = GetPlayerVehicleID(playerid); pvehicleid[playerid] = 0; pmodelid[playerid] = 0; return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER) { pvehicleid[playerid] = GetPlayerVehicleID(playerid); pmodelid[playerid] = GetVehicleModel(pvehicleid[playerid]); } else { pvehicleid[playerid] = 0; pmodelid[playerid] = 0; } return 1; } GetVehicleWithinDistance( playerid, Float:x1, Float:y1, Float:z1, Float:dist, &vehic){ for(new i = 1; i < MAX_VEHICLES; i++){ if(GetVehicleModel(i) > 0){ if(GetPlayerVehicleID(playerid) != i ){ new Float:x, Float:y, Float:z; new Float:x2, Float:y2, Float:z2; GetVehiclePos(i, x, y, z); x2 = x1 - x; y2 = y1 - y; z2 = z1 - z; new Float:iDist = (x2*x2+y2*y2+z2*z2); printf("Vehicle %d is %f", i, iDist); if( iDist < dist){ vehic = i; } } } } } #pragma unused GetVehicleWithinDistance public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp(cmdtext, "/tune", true)) { new playerstate = GetPlayerState(playerid); if(playerstate == PLAYER_STATE_DRIVER) { ShowPlayerDialog(playerid, DIALOG_TYPE_MAIN, DIALOG_STYLE_LIST, "Car Tuning Menu", "Body Work\nEngine Repair\nTire\nLights", "Enter", "Close"); return 1; } else { return SendClientMessage(playerid, COLOR_RED, "[ERROR] You cannot modify/tune a car unless you are the driver."); } } return 0; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == DIALOG_TYPE_MAIN) { if(!response) { SetCameraBehindPlayer(playerid); } if(response) { switch(listitem)// Checking which list item was selected { case 0: // Repair Car { new panels,doors,lights,tires; new car = GetPlayerVehicleID(playerid); tires = encode_tires(0, 0, 0, 0); // fix all tires panels = encode_panels(0, 0, 0, 0, 0, 0, 0); // fix all panels doors = encode_doors(0, 0, 0, 0, 0, 0); // fix all doors lights = encode_lights(0, 0, 0, 0); // fix all lights UpdateVehicleDamageStatus(car, panels, doors, lights, tires); SendClientMessage(playerid,COLOR_WHITE,"[INFO] You have succesfully repaired car"); return 1; } case 1: // Repair engine { new car = GetPlayerVehicleID(playerid); SetVehicleHealth(car,1000); PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0); PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0); PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0); SendClientMessage(playerid,COLOR_WHITE,"[INFO] You have succesfully repaired car"); return 1; } case 2: // Repair tire { new tires; new car = GetPlayerVehicleID(playerid); tires = encode_tires(0, 0, 0, 0); // fix all tires UpdateVehicleDamageStatus(car, tires); SendClientMessage(playerid,COLOR_WHITE,"[INFO] You have succesfully repaired car"); return 1; } case 3: // Repair lights { new lights; new car = GetPlayerVehicleID(playerid); lights = encode_lights(0, 0, 0, 0); // fix all lights UpdateVehicleDamageStatus(car, lights); SendClientMessage(playerid,COLOR_WHITE,"[INFO] You have succesfully repaired car"); return 1; } } } } return 1; }
#include <a_samp>
#include <zcmd>
#include <sscanf2>
enum{
d_tuneveh
};
#define scm SendClientMessage
new PlayerFixVeh[MAX_PLAYERS];
CMD:fixveh(pid){
if(GetPlayerState(pid)!=PLAYER_STATE_DRIVER)return scm(pid,-1,"You are not driver!");
PlayerFixVeh[pid]=GetPlayerVehicleID(pid);
ShowPlayerDialog(pid,d_tuneveh,DIALOG_STYLE_TABLIST_HEADERS,"Select An Option",
"Option\tCost\n{DEDEDE}Engine\t{54CC6A}$86\n{DEDEDE}Bodywork (+ tires)\t{54CC6A}$275\n{DEDEDE}Tires\t{54CC6A}$0\n{DEDEDE}Full repair\t{54CC6A}$361\n{DEDEDE}Healights\t{54CC6A}$50","Select","Cancel");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
new pid=playerid;
switch(dialogid){
case d_tuneveh:{
if(!response)return 0;
new a1,a2,a3,a4;
switch(listitem){
case 0:{
SetVehicleHealth(PlayerFixVeh[pid],1000.0);
scm(pid,-1,"Engine fixed.");
}
case 1:{
}
case 2:{
}
case 3:{
}
case 4:{
}
}
}
}
return 1;
}