Allow Cars to be Unlocked at a Certain Rank?
#1

Ok, I had this idea.

If you reach a certain rank, by the number of kills, or the number of miles you have travelled in a car, or how many stunt jumps you have done, you go up a tank, and a certain car would be unlocked, if you could help me with making a script for this, because I haven't done PAWN scripting for sometime now, I would need some advise on this. If you could help me, I would be very grateful.

Also, is there anyway to make a marker in SA:MP and to start a mission, or does that have to be runned off by a seperate script again? Thanks!
Reply
#2

You could easily use the callback OnPlayerStateChange to see if the player enters a vehicle. If he is not the correct rank, remove him from the vehicle.
Reply
#3

Could you be more specific on how to do this please? I don't want to ask too many questions .
Reply
#4

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
Reply
#5

This might be a bit late as well but, would this be a filterscript?
Reply
#6

no, i added this out of my script, it needs a lot of work for you adopting it into your gamemode. its just for having a look on it.
in my gamemode, it works well: cops needs a certain rank to get (and stay) into a vehicle, and that rank will be the wanted-level for civilians if they steal that vehicle. i also did NOT optimize that with the "id-400" trick so far (vehicles atart 400)...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)