SA-MP Forums Archive
Vehicles Gang - 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: Vehicles Gang (/showthread.php?tid=661615)



Vehicles Gang - KamilPolska - 09.12.2018

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


Re: Vehicles Gang - KamilPolska - 09.12.2018

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


Re: Vehicles Gang - Hunud - 09.12.2018

Huh?


Re: Vehicles Gang - Kontrol - 09.12.2018

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


Re: Vehicles Gang - Kontrol - 09.12.2018

TeamGrove = CreateVehicle(...

or Team[GANGID][0] = CreateVehicle(...


Re: Vehicles Gang - KamilPolska - 09.12.2018

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
}



Re: Vehicles Gang - Altus - 10.12.2018

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.


Re: Vehicles Gang - Calisthenics - 10.12.2018

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.


Re: Vehicles Gang - Altus - 10.12.2018

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


Re: Vehicles Gang - KamilPolska - 11.12.2018

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