SA-MP Forums Archive
car system help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: car system help! (/showthread.php?tid=421852)



car system help! - Yves - 11.03.2013

Okay so here is the message i got!
Well today i been beta testing engine system so i want the cars not to blow up when
it gets to the lowest level damage am not sure how i would script the parts for the
vehicle health to set as 0.300
if you dont no what i am talking about please dont comment

Here is my engine system below


Код:
	if(newstate == PLAYER_STATE_DRIVER)
	{
 		new vehicleid = GetPlayerVehicleID(playerid);
		GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
		if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)
		{
        	SendClientMessage(playerid, COLOR_WHITE,"< To turn on the vehicle engine type {800040}/engine{FFFFFF} - to check radio commands type {800040}/radiohelp{FFFFFF} >");
		}
	}


Код:
	if(strcmp(cmd, "/engine", true) == 0 || strcmp(cmd, "/engine", true) == 0)
	{
        new vid = GetPlayerVehicleID(playerid);
        GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
		if(vid != INVALID_VEHICLE_ID)
		if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be in a vehicle before you can do this!");
		if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_GRAD2, "Only the driver can do this!");
		if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)
		{
            SendClientMessage(playerid, -1, ""#COL_WHITE"> You have "#COL_GREEN" started"#COL_WHITE" the engine");
            GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "* %s takes out the keys - inserts it into the ignition and twists it.", sendername);
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
        else if(engine == VEHICLE_PARAMS_ON)
		{
            SendClientMessage(playerid, -1, ""#COL_WHITE"> You have "#COL_RED"stopped"#COL_WHITE" the engine");
            GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "* %s extends his hand towards the ignition, twisting the keys.", sendername);
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
        }
		return 1;
    }



Re: car system help! - Yves - 11.03.2013

Bump!


Re: car system help! - mineralo - 11.03.2013

pawn Код:
if(strcmp(cmd, "/engine", true) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return scm(playerid,c_r,"( ! ) You're not in any vehicle to use /engine");
        if(GetPlayerVehicleSeat(playerid) !=0) return scm(playerid,c_r,"( ! ) You're not driver of this vehicle for use /engine !");
        new vehicle = GetPlayerVehicleID(playerid);
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
        if(engine != 0)
        {
            SetVehicleParamsEx(vehicle,false,lights,alarm,doors,bonnet,boot,objective);
            scm(playerid,COLOR_GREEN,"( ! ) Engine is off !");
            return 1;
        }
        else if(engine != 1)
        {
            SetVehicleParamsEx(vehicle,true,lights,alarm,doors,bonnet,boot,objective);
            scm(playerid,COLOR_GREEN,"( ! ) Engine is on !");
        }
        return 1;
    }
this cmd from my server,its works, use it


Re: car system help! - LetsOWN[PL] - 11.03.2013

Hello,
Quote:

Well today i been beta testing engine system >> so i want the cars not to blow up when
it gets to the lowest level damage << am not sure how i would script the parts for the
vehicle health to set as 0.300

All I understood is that you don't want your vehicle to explode.
As u know, in GTA SA vehicle is about to explode when engine is on fire.
To prevent it, try something like this:

1) Use this code:
pawn Код:
COMMAND:testdmg(playerid, params[])
{
    new dmgVal;
    if(sscanf(params, "d", dmgVal))
    {
        // 0 - min / 1000 - max
        SetVehicleHealth(GetPlayerVehicleID(playerid), dmgVal);
        new Str[64];
        format(Str, 64, "Current damage: %d", dmgVal);
        SendClientMessage(playerid, Str);
        return 1;
    }
}
2) Get into any vehicle and type /testdmg X where X is number around 10-40. Just see for yourself for what X you given vehicle engine's being burning.

3) Then do something like this (in ur gamemode?)
pawn Код:
public OnGameModeInit()
{

    SetTimer("globalTimer", 500, 1);
    return 1;
}

forward globalTimer();
public globalTimer()
{
    for(new i = 0; i != MAX_PLAYERS; i++)
    {
        new Float:vdmg;
        GetVehicleHealth(GetPlayerVehicleID(playerid), vdmg);
        if(vdmg < X)
        {
            SetVehicleHealth(GetPlayerVehicleID(playerid), Y);
            printf("Vehicle of player %d has been kinda repaired..", i);
        }
    }
}
X - maximum vehicle health, where car's engine starts to burn
Y - minimum vehicle health where car's engine ain't burning.

Perhaps it is that what you meant..
You can use 'globalTimer' for other repeatedly checks (for example to trace player score, XYZ coords, whatever).

Greetz,
LetsOWN



Re: car system help! - mineralo - 11.03.2013

when vehicle gets 250.0 hp its begin be in fire, and after some seconds its blow


Re: car system help! - Yves - 11.03.2013

yea so it would be good idea to set it to 300.0 or something