PDA

View Full Version : a small question


Airblog
07/03/2015, 11:32 AM
Hi All
i have a problem with my cmd. this is for putting criminals in police vehicle!
but i have a question. How to check seatid ? means if a police put a criminal in vehicle then want to put another criminal to his vehicle how to check which seatid the last criminal seat?

CMD:putinveh(playerid, params[])
{
new playerb, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "First login.");
if(!IsACop(playerid) && !IsAFBI(playerid) && !IsASWAT(playerid))return SendClientMessage(playerid, COLOR_GREY, "you are not a cop");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "you are not in any vehicle.");
if(sscanf(params,"u",playerb)) return SendClientMessage(playerid, COLOR_ALIREZA, "USAGE: /putinveh [playerid]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "wrong id.");
if(!IsPlayerNearPlayer(playerid, playerb, 5)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
if(!IsPlayerCuffed(playerb)) return SendClientMessage(playerid, COLOR_GREY, "player is not cuffed.");
PutPlayerInVehicle(playerb, GetPlayerVehicleID(playerid),1); // if someone is sitting in seatid 1 how to seat new criminal in seatid 2?
format(string, sizeof(string), "DepartmentWarn: %s{33AA33} put %s in his vehicle", RPN(playerid));
SendDepMessage(COLOR_BLUE, string);
return 1;
}

Please Help For +Rep
Sorry For Bad English ;)

Nabster
07/03/2015, 12:11 PM
You can use this to get vehicle seat if this is what you meant

http://wiki.sa-mp.com/wiki/GetPlayerVehicleSeat

Airblog
07/03/2015, 12:21 PM
i know this but i want to check which seat is full!

JuanStone
07/03/2015, 12:25 PM
:???:


CMD:putinveh(playerid, params[])
{
new playerb, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "First login.");
if(!IsACop(playerid) && !IsAFBI(playerid) && !IsASWAT(playerid))return SendClientMessage(playerid, COLOR_GREY, "you are not a cop");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "you are not in any vehicle.");
if(sscanf(params,"u",playerb)) return SendClientMessage(playerid, COLOR_ALIREZA, "USAGE: /putinveh [playerid]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "wrong id.");
if(!IsPlayerNearPlayer(playerid, playerb, 5)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
if(!IsPlayerCuffed(playerb)) return SendClientMessage(playerid, COLOR_GREY, "player is not cuffed.");
//--
if(setseatid(playerid) == 3) return SendClientMessage(playerid, "There is no free seats, the vehicle is full.");
//--
PutPlayerInVehicle(playerb, GetPlayerVehicleID(playerid), setseatid(playerid)); // if someone is sitting in seatid 1 how to seat new criminal in seatid 2?
//--
format(string, sizeof(string), "DepartmentWarn: %s{33AA33} put %s in his vehicle", RPN(playerid));
SendDepMessage(COLOR_BLUE, string);
return 1;
}

setseatid(driver)
{
if(GetPlayerVehicleSeat(driver)+1 == 128)
return 1;
else if(GetPlayerVehicleSeat(driver)+2 == 128)
return 2;
else if(GetPlayerVehicleSeat(driver)+3 == 128)
return 3;
else return false;
}

Airblog
07/03/2015, 03:08 PM
:???:


CMD:putinveh(playerid, params[])
{
new playerb, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "First login.");
if(!IsACop(playerid) && !IsAFBI(playerid) && !IsASWAT(playerid))return SendClientMessage(playerid, COLOR_GREY, "you are not a cop");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "you are not in any vehicle.");
if(sscanf(params,"u",playerb)) return SendClientMessage(playerid, COLOR_ALIREZA, "USAGE: /putinveh [playerid]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "wrong id.");
if(!IsPlayerNearPlayer(playerid, playerb, 5)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
if(!IsPlayerCuffed(playerb)) return SendClientMessage(playerid, COLOR_GREY, "player is not cuffed.");
//--
if(setseatid(playerid) == 3) return SendClientMessage(playerid, "There is no free seats, the vehicle is full.");
//--
PutPlayerInVehicle(playerb, GetPlayerVehicleID(playerid), setseatid(playerid)); // if someone is sitting in seatid 1 how to seat new criminal in seatid 2?
//--
format(string, sizeof(string), "DepartmentWarn: %s{33AA33} put %s in his vehicle", RPN(playerid));
SendDepMessage(COLOR_BLUE, string);
return 1;
}

setseatid(driver)
{
if(GetPlayerVehicleSeat(driver)+1 == 128)
return 1;
else if(GetPlayerVehicleSeat(driver)+2 == 128)
return 2;
else if(GetPlayerVehicleSeat(driver)+3 == 128)
return 3;
else return false;
}

it doesn't work :(

Golf
07/03/2015, 03:41 PM
use directly this ;)

public PutPlayerInEmptyVehicleSeat(vehicleid,playerid)
{
new bool:Seat[4];
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i,vehicleid))
{
if(GetPlayerVehicleSeat(i) == 0) Seat[0] = true;
if(GetPlayerVehicleSeat(i) == 1) Seat[1] = true;
if(GetPlayerVehicleSeat(i) == 2) Seat[2] = true;
if(GetPlayerVehicleSeat(i) == 3) Seat[3] = true;
}
}
}
for(new a;a<sizeof(Seat);a++)
{
if(Seat[a] == false) PutPlayerInVehicle(playerid,vehicleid,a);
}
return 1;
}

Airblog
07/03/2015, 06:09 PM
use directly this ;)

public PutPlayerInEmptyVehicleSeat(vehicleid,playerid)
{
new bool:Seat[4];
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i,vehicleid))
{
if(GetPlayerVehicleSeat(i) == 0) Seat[0] = true;
if(GetPlayerVehicleSeat(i) == 1) Seat[1] = true;
if(GetPlayerVehicleSeat(i) == 2) Seat[2] = true;
if(GetPlayerVehicleSeat(i) == 3) Seat[3] = true;
}
}
}
for(new a;a<sizeof(Seat);a++)
{
if(Seat[a] == false) PutPlayerInVehicle(playerid,vehicleid,a);
}
return 1;
}

Thanks so much +rep