How to do this
#1

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
Reply
#2

And the amount of fix should be according to damages i posted this because i cant find any fs regarding this
Reply
#3

I usually don't like asking for a code..

But it should be something like this..

PHP код:
cmd:test(playeridparams[])
{
    if(!
IsPlayerInRangeOfPoint(playerid10.0xxxxxyyyyyyzzzz) return SendClientMessage(playeridcolor_red"you are not near the point!");
    
ShowPlayerDialog(playerid4520DIALOG_STYLE_LIST"Select an option""Engine\nBodyWork\n");
    return 
1;

Reply
#4

I do ask for help because i am new and for the stuff you gave me i already know but how can we fix car body car engine or lights separately and full body repair with the amount co responding to the damage you are dealing with
Reply
#5

To be more specified i need
Visual repair which will only repair body
Engine repair which will only repair engine health
Tire repair which will repair bursted tire
Light repair which will repair broken light
And a full repair includes everthing
Reply
#6

You can create a certain turf and make it invisible as if the player is in range of something,and when hes inside that turf he can perform the desired command,as for the car repair,don't know what to tell you but i can give you some useful hints,If you respawn the player the body of the car will look intact but the actual vehicle HP will be as it is so for example for visual repair you could respawn the player where he was and it'll seem like if the car's body isn't damaged.i don't think repairing only lights and such is possible thought,it might be not sure
Reply
#7

UpdateVehicleDamageStatus(vehid, panels, doors, lights, tires);
SetVehicleHealth(vehid, 1000.0);
with these two function i can achieve what i want but how to set the repair amount on the amount of damage to the car ?
Reply
#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
#9

Help?
Reply
#10

PHP код:
#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(playeriddialogidresponselistiteminputtext[]){
    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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)