Team Vehicles - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Team Vehicles (
/showthread.php?tid=206212)
Team Vehicles -
wilko1995 - 03.01.2011
Hi,
How would i make it if a player entered a vehicle and they were in "gTeam A", but the Vehicle is in "gTeam PD", how would i make the Player Exit the vehicle?
I have this code but i dont know why it doesnt work... And what call back would i place it in?
Код:
if(IsPlayerInVehicle(playerid, PDcar || PDcar1 || PDcar2 || PDcar3 || PDcar4 || PDcar5 ||PDcar6))
{
if(gTeam[playerid] == PD)
{
SendClientMessage(playerid, 0x0000FFAA, "You are driving a police vehicle");
return 1;
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0xFF0000AA, "Join the police faction to drive this vehicle");
return 1;
}
}
Re: Team Vehicles -
azzerking - 03.01.2011
What Error You Get?
Re: Team Vehicles -
wilko1995 - 03.01.2011
i dont get any error it just doesnt work ingame... If i enter the vehicle with a player in a gTeam other then PD it doesnt remove them from the vehicle or send the message, and if i enter with a player in gTeam PD it doesnt send the message to them...
I just need to know if that is the right way to make the function and what call back to put it in
Re: Team Vehicles -
Jeffry - 03.01.2011
Try:
pawn Код:
if(IsPlayerInAnyVehicle(playerid))
{
new v = GetPlayerVehicleID(playerid);
if(v==PDcar || v==PDcar1 || v==PDcar2 || v==PDcar3 || v==PDcar4 || v==PDcar5 ||v==PDcar6)
{
if(gTeam[playerid] == PD)
{
SendClientMessage(playerid, 0x0000FFAA, "You are driving a police vehicle");
return 1;
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0xFF0000AA, "Join the police faction to drive this vehicle");
return 1;
}
}
}
Re: Team Vehicles -
wilko1995 - 03.01.2011
Where do i put that? What Callback?
Re: Team Vehicles -
JamesC - 03.01.2011
pawn Код:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( newstate == PLAYER_STATE_DRIVER )
{
new veh = GetPlayerVehicleID( playerid );
if( veh == PDcar1 || veh == PDcar2 || veh == PDcar3 || veh == PDcar4 || veh == PDcar5 || veh == PDcar6 )
{
if( gTeam[ playerid ] != PD ) // Guessing that PD defined as the team number.
{
RemovePlayerFromVehicle( playerid );
SendClientMessage( playerid, 0xFF0000AA, "Join the police faction to drive this vehicle" );
}
}
}
return 1;
}
Untested. It would be better to put the PD cars in an array, then loop through it to check if 'veh' equals any of them.
Re: Team Vehicles -
wilko1995 - 03.01.2011
that doesnt work