Vehicles Gang
#1

How to create vehicles belonging to a gang?
For this gamemode:
https://sampforum.blast.hk/showthread.php?tid=590991
Reply
#2

How? AddStaticVehicleEx and public OnPlayerStateChange. I have Team[i][TeamID], You could do, for example: TeamCar[][]
Reply
#3

Huh?
Reply
#4

You want to be able to create a car which only certain teams can enter?
Reply
#5

TeamGrove = CreateVehicle(...

or Team[GANGID][0] = CreateVehicle(...
Reply
#6

Yes.
How to make public OnPlayerStateChange?

Код:
new GangCar[3][2];

Vehicles()
{
GangCar[0][0] = AddStaticVehicleEx(560, 2488.8835, -1682.5499, 12.9978, 88.5095, 234, 0, 60*4); //GrovesCar
GangCar[0][1] = AddStaticVehicleEx(560, 2505.8076, -1676.9358, 13.0382, 145.1543, 234, 0, 60*4); //GrovesCar
	
GangCar[1][0] = AddStaticVehicleEx(566, 1942.0941, -1131.7699, 25.1147, 269.9582, 242, 0, 60*4); //BallasCar
GangCar[1][1] = AddStaticVehicleEx(566, 1922.3245, -1131.7358, 24.7656, 269.2967, 242, 0, 60*4); //BallasCar
	
GangCar[2][0] = AddStaticVehicleEx(467, 2456.3350, -1270.5421, 23.6457, 180.9951, 6, 6, 60*4); //VagosCar
GangCar[2][1] = AddStaticVehicleEx(467, 2445.8972, -1271.0826, 23.6627, 179.5045, 6, 6, 60*4); //VagosCar
}
Reply
#7

Hi, in order to lock the vehicles for everyone but the members of the particular team, you should write something like the following (not compiled/tested, just a sketch):
Код:
#define TEAMS 10

new number_of_vehicles[TEAMS];
new team_vehicles[MAX_VEHICLES] = { INVALID_VEHICLE_ID, ... };

CreateTeamVehicle(team_id, modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2) {
	if (team_id < 0 || team_id >= TEAMS) return INVALID_VEHICLE_ID;
	
	new vehicle_id = AddStaticVehicle(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2);
	
	team_vehicles[vehicle_id] = team_id;
	return vehicle_id;
}

GetVehicleTeam(vehicleid) {
	return team_vehicles[vehicleid];
}

public OnVehicleStreamIn(vehicleid, forplayerid) {
	SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, GetPlayerTeam(forplayerid) != GetVehicleTeam(vehicleid));
}
You need to create the vehicles at OnGameModInit (or OnFilterScriptInit) with the CreateTeamVehicle function. Then, if a vehicle is streamed in for a member of the team, it will be unlocked, otherwise locked. Keep in mind that all the vehicles will still be unlocked for passengers.
Reply
#8

Altus, NO_TEAM is defined as 255 which is a valid vehicleid. Replace with INVALID_VEHICLE_ID. CreateTeamVehicle is better to keep the same return values as AddStaticVehicle, INVALID_VEHICLE_ID for limit being reached or invalid modelid to also avoid run time error otherwise the vehicleid returned.
Reply
#9

Oh no, I was so inattentive. Calisthenics, of course you're right. Corrected, thank you very much.
Reply
#10

It works. How to make a SendClientMessage message for example for Ballas. Message: "This vehicle belongs to Groves".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)