try this - on top, add:
Код:
const ScorePerRank=3;//kills needed for 1 rank
new gCarRequiredRank[700];//array (ID of vehicle) which holds the rank needed to enter vehicle
new gRank[MAX_PLAYERS];//actual players rank, set it whereever u want, look @ OnPlayerDeath()
new gScore[MAX_PLAYERS];//well...
#define RAISED_COLOR 0x5fffafff
#define DEMOTED_COLOR 0xff5fafff
add some ranks needed to enter vehicles (i didnt modify the array with the "spare the 400 empty slots"...)
Код:
public OnGameModeInit()
{
//...
gCarRequiredRank[487]=1;//Maverick
gCarRequiredRank[488]=1;//News Chopper
gCarRequiredRank[411]=1;//Infernus
gCarRequiredRank[415]=1;//Cheetah
gCarRequiredRank[451]=1;//Tourismo
gCarRequiredRank[429]=1;//Banshee
gCarRequiredRank[596]=1;//Cop Car LS
gCarRequiredRank[597]=1;//Cop Car SF
gCarRequiredRank[598]=1;//Cop Car LV
gCarRequiredRank[523]=1;//Cop HPV-1000
gCarRequiredRank[599]=1;//Cop Ranger
gCarRequiredRank[497]=1;//Cop Maverick
gCarRequiredRank[480]=2;//FBI Ranger
gCarRequiredRank[599]=3;//SWAT
gCarRequiredRank[476]=4;//Rustler
gCarRequiredRank[432]=5;//Rhino
gCarRequiredRank[520]=5;//Hydra
gCarRequiredRank[425]=5;//Hunter
//...
}
the eject-player-from-vehicle-part...
Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
//...
if(newstate == PLAYER_STATE_DRIVER)
{
if (gRank[playerid]<gCarRequiredRank[GetVehicleModel(GetPlayerVehicleID(playerid))])
{
new string[64];
format(string,sizeof(string),"You need a higher Rank (%i) to use this Vehicle",gCarRequiredRank[GetVehicleModel(GetPlayerVehicleID(playerid))]);
SendClientMessage(playerid,MSGFAIL_COLOR,string);
RemovePlayerFromVehicle(playerid);
return 1;
}
}
//...
}
and finally, as suggestion for a ranking-system:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
//...
gScore[playerid]-=1;
if (gScore[playerid]<-(ScorePerRank-1)
{
gScore[playerid]+=ScorePerRank;
gRank[playerid]-=1;
new string[48];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"%s(%d) Demoted to Rank: %i",name,playerid,gRank[playerid]);
SendClientMessageToAll(DEMOTED_COLOR,string);
}
gScore[killerid]+=1;
if (gScore[killerid]>ScorePerRank-1
{
gScore[killerid]-=ScorePerRank;
gRank[killerid]+=1;
new string[48];
new name[MAX_PLAYER_NAME];
GetPlayerName(killerid,name,sizeof(name));
format(string,sizeof(string),"%s(%d) Raised to Rank: %i",name,killerid,gRank[playerid]);
SendClientMessageToAll(RAISED_COLOR,string);
}
//...
}
hf testing it