29.07.2011, 01:08
Im working on a Team Deathmatch gamemode right now and im trying to do ranks. So, i want it if you get 50 kills you will go to rank 1, 100 kills to rank 2 and so on. How would i do this?
new Kills[MAX_PLAYERS]; // This is global, btw.
Kills[killerid]++;
if(Kills[killerid] >= 50)
{
//run your rank code here
}
else if(Kills[killerid] >= 100)
{
//higher rank code
}
Use a variable to count the kills:
pawn Код:
pawn Код:
pawn Код:
|
new pRank[MAX_PLAYERS];
if(Kills[killerid] >= 50)
{
if(pRank[killerid] == 0)
{
pRank[killerid] = 1;
SendClientMessage(killerid, whatever, "You have gained the blah blah rank!"); // You could maybe time this in a function so it shows when they spawn.
}
//run your rank code here
}
else if(Kills[killerid] >= 100)
{
//higher rank code
}
I don't know, maybe a global variable for example:
pawn Код:
pawn Код:
|
new hydra;
if(vehicleid == hyrda)
{
if(pRank(playerid) => 2)
{
//Whatever you want it to do if he is the right rank
}
else
{
SendClientMessage(...."You cant use this till rank 2");
RemovePlayerFromVehicle(playerid);
}
}
hydra = CreateVehicle(id, x,y,z,respawn);
if(newstate == PLAYER_STATE_DRIVER)
{
new model = GetVehicleModel(vehicleid);
if(model == 520)
{
if(pRank[playerid] < 2)
{
SendClientMessage(playerid, color, "You are not allowed to use this vehicle!");
RemovePlayerFromVehicle(playerid);
}
}
}
No worries this is how ive been learning to code, ive tried for hours to fix my own code, if i cant i ask for help, then i take the code that has been given to me and modify it so that it fits with my server, and try to always right the code out instead of copy and pasting because even though its quicker to copy and paste you will remember more by keep typing it out. ive only been coding for about 2 weeks and ive learned quite alot =P And yes the Include looks awsome =P itll help me alot hehe |
new rank[128];
if(pRank[playerid] == 1)
{
rank = "Rank Name for Rank 1";
}
if(pRank[playerid] == 2)
{
rank = "Rank name for rank 2";
}
if(etc. etc..)
{
//another rank
}
else if(pRank[playerid] == 0) // unset .. no rank.
{
rank = "No rank";
}
format(string, sizeof(string), "Player rank: %s", rank);
Are you scripting this in a game-mode that already saves player stuff? Or in some standalone filterscript?
for the stats command you'd just need to do something like this: pawn Код:
pawn Код:
|
format(string, sizeof(string), "Player rank: %s", rank);