[Question] Looking for vehicle function. - 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: [Question] Looking for vehicle function. (
/showthread.php?tid=443127)
[Question] Looking for vehicle function. -
tony_fitto - 10.06.2013
Dear SAMP:er's
I'm creating radio system for vehicle's and are looking for a function to get playerid's of those who are inside the same vehicles as the guy changing radio, any ideas how?
-Sincerely,
Tony
Respuesta: [Question] Looking for vehicle function. -
Parka - 10.06.2013
GetPlayerVehicleSeat
pawn Код:
if(strcmp(cmdtext, "/myseat", true) == 0)
{
new szString[14], iSeat = GetPlayerVehicleSeat(playerid);
if(iSeat == 128) return SendClientMessage(playerid, 0xFFFFFFFF, "An error has prevented us from returning the seat ID.");
format(szString, sizeof(szString), "Your seat: %i", iSeat);
SendClientMessage(playerid, 0xFFFFFFFF, szString);
return 1;
}
Re: [Question] Looking for vehicle function. -
Aly - 10.06.2013
It's kinda easy.
Well you can get the player's car ID and then make a loop to check if there are another players in the same car and to be a little bit better make a variable "persinthecar"(example) and everytime he found a person in the same car persinthecar++; when persinthecar reaches 3 use the function break;
Be careful to avoid in the loop the player who changed the radio: "if(playerid != i)"
It will look like:
pawn Код:
new persinthecar,newcar;
newcar = GetPlayerVehicleID(playerid);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(playerid != i)
{
if(newcar == GetPlayerVehicleID(i))
{
//Change the stream....
}
}
}