How would i to do this?
#1

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?
Reply
#2

Use a variable to count the kills:

pawn Код:
new Kills[MAX_PLAYERS]; // This is global, btw.
Count the kills on OnPlayerDeath

pawn Код:
Kills[killerid]++;
Also in OnPlayerDeath, run a check:

pawn Код:
if(Kills[killerid] >= 50)
{
    //run your rank code here
}
else if(Kills[killerid] >= 100)
{
    //higher rank code
}
For the ranks, I'd use a global variable, ie/ rank = 1; would be rank 1, rank = 2; for rank 2, etc.
Reply
#3

Quote:
Originally Posted by Famalamalam
Посмотреть сообщение
Use a variable to count the kills:

pawn Код:
new Kills[MAX_PLAYERS]; // This is global, btw.
Count the kills on OnPlayerDeath

pawn Код:
Kills[killerid]++;
Also in OnPlayerDeath, run a check:

pawn Код:
if(Kills[killerid] >= 50)
{
    //run your rank code here
}
else if(Kills[killerid] >= 100)
{
    //higher rank code
}
For the ranks, I'd use a global variable, ie/ rank = 1; would be rank 1, rank = 2; for rank 2, etc.
Kk, so i have it like you said, but now, the Ranks, what would those be like?
Reply
#4

I don't know, maybe a global variable for example:

pawn Код:
new pRank[MAX_PLAYERS];
Obviously, you'd need to save these in a player file if you want to keep them.

pawn Код:
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
}
Then, maybe show the rank in a textdraw, you can then use the pRank variable in commands and shit, so if you wanted to show it in your stats command or something, or a command to show highest ranking players.
Reply
#5

Quote:
Originally Posted by Famalamalam
Посмотреть сообщение
I don't know, maybe a global variable for example:

pawn Код:
new pRank[MAX_PLAYERS];
Obviously, you'd need to save these in a player file if you want to keep them.

pawn Код:
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
}
Then, maybe show the rank in a textdraw, you can then use the pRank variable in commands and shit, so if you wanted to show it in your stats command or something, or a command to show highest ranking players.
OKay, thanks it all worked great. Thank you but one more thing and thats it! i want it so if your Rank 2 and beyond you would become able to use the Hydra, and if your less than level 2, you dont get to use Hydra
Reply
#6

something like this

at the top of your code:
pawn Код:
new hydra;
then on player enter vehicle:
pawn Код:
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);
}
}
Correct me if im wrong =P
Reply
#7

O and i forgot In ongamemodeini do a vehicle like so:

pawn Код:
hydra = CreateVehicle(id, x,y,z,respawn);
I think thats right
Reply
#8

In OnPlayerStateChange:
pawn Код:
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);
            }
        }
    }
Should work aye-ok.
Reply
#9

Was myn wrong?
Reply
#10

No, by all means yours would work fine, but just for the vehicle you created "hydra". The code I wrote would stop players below rank 2 from using any Hydra's, anywhere.
Reply
#11

ahhhhhh that could be usefull to me right now actually thanks double helpings =p

killed 2 birds with 1 stone =P
Reply
#12

Haha, I'm glad I helped
Reply
#13

Aswell as your spawn protection include could be very helpfull to me =P
Reply
#14

Great, it's been out for a while now I wasn't sure how useful it would be since the lack of feedback it's only simple, but if it helps people understand then it's all good.
Reply
#15

Thanks guys for helping me, it compiled A-OK
Reply
#16

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

Quote:
Originally Posted by Shockey HD
Посмотреть сообщение
Thanks guys for helping me, it compiled A-OK
Awesome

Quote:

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

2 weeks, huh? Heh, I remember when I first started scripting in Summer '09, I coded non-stop all Summer I was that hooked needless to say it didn;t do much for my tan

Anyway, if you need anymore help don't hesitate to PM.
Reply
#18

Okay so i lied, i got all the things i wanted, Thank you but remember how you said the stats? How would i do that? And the thing you told me to do, does the amount of kills save?
Reply
#19

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 Код:
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";
}
Then just use the "rank" variable in a formatted string:

pawn Код:
format(string, sizeof(string), "Player rank: %s", rank);
Then add that to the stats command. I'm sure you can make your own stats command
Reply
#20

Quote:
Originally Posted by Famalamalam
Посмотреть сообщение
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 Код:
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";
}
Then just use the "rank" variable in a formatted string:

pawn Код:
format(string, sizeof(string), "Player rank: %s", rank);
Then add that to the stats command. I'm sure you can make your own stats command
I got it all added except

PHP код:
format(stringsizeof(string), "Player rank: %s"rank); 
LOL, Where would i put this?
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)