[SOLVED] Kick player from a car id? -
FreddeN - 19.02.2010
Hello, I'm using a hard type of this script, I have to give every car a name like PoliceCar1 and it's like 50 Police Cars.
Example:
Код:
new PoliceCar1
new PoliceCar2
new PoliceCar3
Код:
PoliceCar1 = AddStaticVehicleEx(596,1585.6294,-1671.8558,5.6147,270.2157,0,1,3600);
PoliceCar2 = AddStaticVehicleEx(596,1585.6694,-1667.5063,5.6124,270.3781,0,1,3600);
PoliceCar3 = AddStaticVehicleEx(596,1601.5731,-1683.8987,5.6119,89.8711,0,1,3600);
Код:
if(Vehicle == PoliceCar1)
{
if(gTeam[playerid] == TEAM_LSPD)
{
if(PlayerInfo[playerid][pLAERank] >= 1)
{
}
else
{
SendClientMessage(playerid, COLOR_GREY," You are not authorized to use that vehicle.");
RemovePlayerFromVehicle(playerid);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY," You are not a Police Officer.");
RemovePlayerFromVehicle(playerid);
}
}
if(Vehicle == PoliceCar2)
{
if(gTeam[playerid] == TEAM_LSPD)
{
if(PlayerInfo[playerid][pLAERank] >= 1)
{
}
else
{
SendClientMessage(playerid, COLOR_GREY," You are not authorized to use that vehicle.");
RemovePlayerFromVehicle(playerid);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY," You are not a Police Officer.");
RemovePlayerFromVehicle(playerid);
}
}
if(Vehicle == PoliceCar3)
{
if(gTeam[playerid] == TEAM_LSPD)
{
if(PlayerInfo[playerid][pLAERank] >= 1)
{
}
else
{
SendClientMessage(playerid, COLOR_GREY," You are not authorized to use that vehicle.");
RemovePlayerFromVehicle(playerid);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY," You are not a Police Officer.");
RemovePlayerFromVehicle(playerid);
}
}
So, as I was saying, it it possible to switch the names of the cars to the car's ID so I dont have to put names on every car and ad so many lines, like remove the PolceCar1 to the car id's so I only have to make one line on PlayerStateChange for all the police cars.
Thanks
Re: [HELP] Kick player from a car id? -
TTJJ - 19.02.2010
Hi there FreddeN,
I cant see much of an issue with your code... Just incase here is how I would do it:
Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new veh = GetPlayerVehicleID(playerid);
if(veh == PoliceCar1)
{
if(gTeam[playerid] == TEAM_LSPD && PlayerInfo[playerid][pLAERank] < 1)
{
SendClientMessage(playerid,COLOR_GREY," You are not authorized to use that vehicle.");
RemovePlayerFromVehicle(playerid);
}
else if(gTeam[playerid] != TEAM_LSPD)
{
SendClientMessage(playerid,COLOR_GREY," You are not a police officer");
RemovePlayerFromVehicle(playerid);
}
}
}
}
Give it a try, make sure it works
Cheers,
TJ
Re: [HELP] Kick player from a car id? -
woot - 19.02.2010
Create an array and put the vehicles into them, then simply loop through it.
This is untested though ..
pawn Код:
new PoliceCar[ 50 ]; // top of your script
PoliceCar[ 0 ] = AddStaticVehicleEx(596,1585.6294,-1671.8558,5.6147,270.2157,0,1,3600);
PoliceCar[ 1 ] = AddStaticVehicleEx(596,1585.6694,-1667.5063,5.6124,270.3781,0,1,3600);
PoliceCar[ 2 ] = AddStaticVehicleEx(596,1601.5731,-1683.8987,5.6119,89.8711,0,1,3600);
// OnPlayerStateChange
for(new p; p < sizeof(PoliceCar); p++)
{
if(Vehicle == p)
{
if(gTeam[playerid] != TEAM_LSPD)
{
SendClientMessage(playerid, COLOR_GREY," You are not a Police Officer.");
return RemovePlayerFromVehicle(playerid);
}
if(PlayerInfo[playerid][pLAERank] < 1)
{
SendClientMessage(playerid, COLOR_GREY," You are not authorized to use that vehicle.");
return RemovePlayerFromVehicle(playerid);
}
}
}
Re: [HELP] Kick player from a car id? -
Nero_3D - 19.02.2010
Dadadada, modelid
pawn Код:
//OnPlayerStateChange
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new modelid = GetVehicleModel(vehicleid);
if(modelid == 596)
{
if(gTeam[playerid] == TEAM_LSPD)
{
if(PlayerInfo[playerid][pLAERank] < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You are not authorized to use that vehicle.");
RemovePlayerFromVehicle(playerid);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not a police officer");
RemovePlayerFromVehicle(playerid);
}
}
}
Re: [HELP] Kick player from a car id? -
FreddeN - 19.02.2010
Thank you dudes, both of them works
Have a good one.