Small question. - 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: Small question. (
/showthread.php?tid=604867)
Small question. -
KillerDVX - 10.04.2016
Hello guys.
I'm making a detain system, I succeded with that, but the only problem I've got is making different detained players seats.
I wan't to make the maximum of detained players 3, and each one in different seat.
I've got this as a command:
PHP код:
dcmd_detenir(playerid,params[])
{
new string[128];
new ID;
if(sscanf(params, "u", ID))
{
SendClientMessage(playerid,COLOR_ERROR,"Utilisation: /detenir (Nom de joueur/ID)");
return 1;
}
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_ERROR,"Vous devez spawn pour pouvoir utiliser cette commande.");
return 1;
}
format(string,sizeof(string),"[RADIO DE POLICE] L'officier de police %s(%d) a dйtenu %s(%d) dans son vйhicule.",PlayerName(playerid),playerid,PlayerName(ID),ID);
SendClientMessageToAll(COLOR_DODGERBLUE,string);
SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Detenir_]]");
format(string,sizeof(string),"L'officier de police %s(%d) vous a dйtenu.",PlayerName(playerid),playerid);
SendClientMessage(ID,COLOR_DODGERBLUE,string);
SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Detenir_]]");
format(string,sizeof(string),"Vous avez dйtenu %s(%d) dans votre vehicule.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_DODGERBLUE,string);
GameTextForPlayer(ID,"~R~Vous avez ete detenu par un policier . Aie vous кtes foutue :/.",5000,4);
PutPlayerInVehicle(ID,LastVehicle[playerid],I wan't a random seat here);
return 1;
}
Thanks in advance.
Re: Small question. - Jelly23 - 11.04.2016
PHP код:
dcmd_detenir(playerid,params[])
{
new string[128];
new ID;
if(sscanf(params, "u", ID))
{
SendClientMessage(playerid,COLOR_ERROR,"Utilisation: /detenir (Nom de joueur/ID)");
return 1;
}
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_ERROR,"Vous devez spawn pour pouvoir utiliser cette commande.");
return 1;
}
format(string,sizeof(string),"[RADIO DE POLICE] L'officier de police %s(%d) a dйtenu %s(%d) dans son vйhicule.",PlayerName(playerid),playerid,PlayerName(ID),ID);
SendClientMessageToAll(COLOR_DODGERBLUE,string);
SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Detenir_]]");
format(string,sizeof(string),"L'officier de police %s(%d) vous a dйtenu.",PlayerName(playerid),playerid);
SendClientMessage(ID,COLOR_DODGERBLUE,string);
SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Detenir_]]");
format(string,sizeof(string),"Vous avez dйtenu %s(%d) dans votre vehicule.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_DODGERBLUE,string);
GameTextForPlayer(ID,"~R~Vous avez ete detenu par un policier . Aie vous кtes foutue :/.",5000,4);
new Seats = PutPlayerInEmptyVehicleSeat(LastVehicle[playerid],ID);
if(Seats != INVALID_PLAYER_ID)
{
SendClientMessage(playerid,COLOR_ERROR,"No free seats");
}
return 1;
}
forward PutPlayerInEmptyVehicleSeat(vehicleid,playerid);
public PutPlayerInEmptyVehicleSeat(vehicleid,playerid)
{
new bool:Seat[4],seat;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInVehicle(i,vehicleid))
{
seat = GetPlayerVehicleSeat(i);
if(!(0 <= seat < sizeof(Seat))) seat = sizeof(Seat)-1;
Seat[seat] = true;
}
}
for(new seatID = sizeof(Seat)-1; seatID > -1; seatID--)
if(!Seat[seatID])
{
seat = INVALID_PLAYER_ID;
PutPlayerInVehicle(playerid,vehicleid,seatID);
break;
}
return seat;
}
Re: Small question. -
KillerDVX - 11.04.2016
It doesn't function well: if(Seats != INVALID_PLAYER_ID)