SA-MP Forums Archive
Vehicle type - 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: Vehicle type (/showthread.php?tid=597438)



Vehicle type - yvoms - 31.12.2015

Hello guys,
im in need of a heads up,
Im trying to edit my vehicle system to set the type,
certain vehicles for army certains for leo only this to be set in the database.
I have put it in a enum and defined the vehicle types, however im not sure on how to load the actual vehicle type.

Veh_type definitions
Код:
#define VEHICLE_TYPE_GLOBAL (0)
#define VEHICLE_TYPE_LEO 	(1)
#define VEHICLE_TYPE_ARMY   (2)
Vehicle enumrator
Код:
enum server_veh
{
        ORM:ORM_ID,
        ID,
        Model,
        Color[2],
        Plate[MAX_PLATE_NAME],
        Float:Spawn[4],
        Type
};
And the database structure
Код:
CREATE TABLE `server_vehicles` (
	`veh_id` INT(5) NOT NULL,
	`veh_model` INT(5) NOT NULL,
	`veh_color_1` INT(5) NOT NULL,
	`veh_color_2` INT(5) NOT NULL,
	`veh_plate` VARCHAR(40) NOT NULL,
	`veh_x` FLOAT(12,4) NOT NULL,
	`veh_y` FLOAT(12,4) NOT NULL,
	`veh_z` FLOAT(12,4) NOT NULL,
	`veh_a` FLOAT(12,4) NOT NULL,
	`veh_type` INT(11) NULL DEFAULT '0',
	PRIMARY KEY (`veh_id`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;
Load vehicles Query
Код:
mysql_pquery(Database,"SELECT * FROM `server_vehicles` ORDER BY `veh_id` ASC","Vehicle_Load","");
And the vehicle load function
Код:
function Vehicle_Load()
{
        new rows = cache_get_row_count(Database);
        if(rows != 0)
        {
            forex(row,rows)
            {
                new vehicleid = cache_get_row_int(row,0,Database);
                new ORM:ormid = ServerVehicle[vehicleid][ORM_ID] = orm_create("server_vehicles",Database);
                orm_addvar_int(ormid,ServerVehicle[vehicleid][ID],"veh_id");
                orm_addvar_string(ormid,ServerVehicle[vehicleid][Plate],MAX_PLATE_NAME,"veh_plate");
                orm_addvar_int(ormid,ServerVehicle[vehicleid][Model],"veh_model");
                orm_addvar_int(ormid,ServerVehicle[vehicleid][Color][0],"veh_color_1");
                orm_addvar_int(ormid,ServerVehicle[vehicleid][Color][1],"veh_color_2");
                orm_addvar_float(ormid,ServerVehicle[vehicleid][Spawn][0],"veh_x");
                orm_addvar_float(ormid,ServerVehicle[vehicleid][Spawn][1],"veh_y");
                orm_addvar_float(ormid,ServerVehicle[vehicleid][Spawn][2],"veh_z");
                orm_addvar_float(ormid,ServerVehicle[vehicleid][Spawn][3],"veh_a");
                orm_addvar_int(ormid,ServerVehicle[vehicleid][Type],"veh_type");
                orm_apply_cache(ormid,row);
                orm_setkey(ormid,"veh_id");
                Vehicle_Create(vehicleid,INVALID_PLAYER_ID);
            }
            printf(" [Vehicle System] Loaded %d vehicles.", rows);
        }
        return 1;
}
Patrick told me to load the veh_type OnPlayerEnterVehicle
if(vehicleid == rowid == veh_type)
But i have no clue on how this works,
So im hoping someone could assist me with this.
Veh_type 0 should do nothing,
Veh_type 1 Should give a player a message and +3 wanted level
Veh_type 2 Should give a player a message +3 wanted and eject from the vehicle.

I hope someone is able to help me with this as its needed very much on the gamemode.
Thanks in advance
Yvoms


Re: Vehicle type - yvoms - 01.01.2016

bump?


Re: Vehicle type - yvoms - 01.01.2016

This wouldn't do it right?

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if (ServerVehicle[Type], vehicleid == 0)
	{
		return 1;
	}
	return 1;
}



Re: Vehicle type - jlalt - 01.01.2016

PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if (
ServerVehicle[vehicleid][Type] == 0)
    {
        return 
1;
    }
    return 
1;

And do same for others


Re: Vehicle type - yvoms - 01.01.2016

Fixed, @jlalt that wouldn't work.


Re: Vehicle type - yvoms - 01.01.2016

it was like this.
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if(gTeam[playerid] == TEAM_CIVIL && ServerVehicle[vehicleid][Type] == VEHICLE_TYPE_LEO)
		{ 
			SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 3);
			SendClientMessage(playerid, -1, "You have stolen a Law Enforcement Vehicle and therefor got wanted!");
			return 1;
		}
	if(gTeam[playerid] == TEAM_CIVIL && ServerVehicle[vehicleid][Type] == VEHICLE_TYPE_ARMY)
		{ 
			SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 3);
			SendClientMessage(playerid, -1, "Only the army is able to use these vehicles, you got wanted for attempting to steal one!");
			return 1;
		}
	return 1;
}