How to do this
#8

here is what i did until now and it works how i wanted it to be i am just confused with the repair amount and how will that work co responding to the damage held to body and it should show like in the above displayed image
Код:
#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;
}
Thank you
Reply


Messages In This Thread
How to do this - by Astonish - 15.05.2018, 20:37
Re: How to do this - by Astonish - 15.05.2018, 20:39
Re: How to do this - by JasonRiggs - 15.05.2018, 20:46
Re: How to do this - by Astonish - 15.05.2018, 20:56
Re: How to do this - by Astonish - 15.05.2018, 21:38
Re: How to do this - by Ha$H_Sexyboy - 15.05.2018, 23:34
Re: How to do this - by Astonish - 16.05.2018, 03:20
Re: How to do this - by Astonish - 16.05.2018, 04:18
Re: How to do this - by Astonish - 16.05.2018, 10:08
Re: How to do this - by CodeStyle175 - 16.05.2018, 12:07

Forum Jump:


Users browsing this thread: 2 Guest(s)