How do I do this?
#1

I would like to create rank system for police officers. After they arrest or ticket so many players their rank goes up to a new one with a new rank name. The rank would also need to save to their file so the next time they join they will still have it. Thanks in advance!
Reply
#2

Quote:
Originally Posted by Seif_
You do this by using:
file functions,
variables,
variable storing names.
I figured that I am just not sure how to set it up properly.. I need an example, that would really help a lot!
Reply
#3

Quote:
Originally Posted by Seif_
You seem like you're asking for the code itself. Look for account saving tutorials(there's mine) or in scripts. The counting part is simple if you figured out what to use.
No read what I wrote I am asking for an example of how I would do this. I have no issue doing things myself I would just like to see how/where I would place these in the format so I don't screw things up. I am a visual learner and I can do the rest myself I am just asking for an example so I know how it would look, and then I could learn from that.
Reply
#4

Make globals
pawn Код:
new
    policeRanksVar[MAX_PLAYERS], //storing the players rank
    arrestCount[MAX_PLAYERS], //used for counting how many players the player has arrested
    ticketCount[MAX_PLAYERS], //used for counting how many players the player has given a ticket
    rank1Players = 5;
    rank2Players = 10;
    rank3Players = 20;
    rank4Players = 40;
    rank5Players = 80;

new policeRanksNames[][] = //the rank names stored in a string variable
{
    "Rank1",
    "Rank2",
    "Rank3",
    "Rank4",
    "Rank5" //etc
};
Then use them as you like (above was just a example)
i.e. use arrestCount every time a player gets arrested
set a timer to go on and on all the time to check how many players you have arrested/ticketed, then if it's equal to the amount in the rank#Players variables...

pawn Код:
//timer function
myTimer(playerid)
{
    if(policeRanksVar[playerid] == 0 && arrestCount[playerid]+ticketCount[playerid]>=rank1Players)
        policeRanksVar[playerid] = 1;
    if(policeRanksVar[playerid] == 1 && arrestCount[playerid]+ticketCount[playerid]>=rank2Players)
        policeRanksVar[playerid] = 2;
    if(policeRanksVar[playerid] == 2 && arrestCount[playerid]+ticketCount[playerid]>=rank3Players)
        policeRanksVar[playerid] = 3;
    if(policeRanksVar[playerid] == 3 && arrestCount[playerid]+ticketCount[playerid]>=rank4Players)
        policeRanksVar[playerid] = 4;
    if(policeRanksVar[playerid] == 4 && arrestCount[playerid]+ticketCount[playerid]>=rank5Players)
        policeRanksVar[playerid] = 5;
    return true;
}
Just an example, I don't recommend using the identical same method, but it should work (untested, not even compiled)
Reply
#5

Quote:
Originally Posted by lrZ^
Make globals
pawn Код:
new
    policeRanksVar[MAX_PLAYERS], //storing the players rank
    arrestCount[MAX_PLAYERS], //used for counting how many players the player has arrested
    ticketCount[MAX_PLAYERS], //used for counting how many players the player has given a ticket
    rank1Players = 5;
    rank2Players = 10;
    rank3Players = 20;
    rank4Players = 40;
    rank5Players = 80;

new policeRanksNames[][] = //the rank names stored in a string variable
{
    "Rank1",
    "Rank2",
    "Rank3",
    "Rank4",
    "Rank5" //etc
};
Then use them as you like (above was just a example)
i.e. use arrestCount every time a player gets arrested
set a timer to go on and on all the time to check how many players you have arrested/ticketed, then if it's equal to the amount in the rank#Players variables...

pawn Код:
//timer function
myTimer(playerid)
{
    if(policeRanksVar[playerid] == 0 && arrestCount[playerid]+ticketCount[playerid]>=rank1Players)
        policeRanksVar[playerid] = 1;
    if(policeRanksVar[playerid] == 1 && arrestCount[playerid]+ticketCount[playerid]>=rank2Players)
        policeRanksVar[playerid] = 2;
    if(policeRanksVar[playerid] == 2 && arrestCount[playerid]+ticketCount[playerid]>=rank3Players)
        policeRanksVar[playerid] = 3;
    if(policeRanksVar[playerid] == 3 && arrestCount[playerid]+ticketCount[playerid]>=rank4Players)
        policeRanksVar[playerid] = 4;
    if(policeRanksVar[playerid] == 4 && arrestCount[playerid]+ticketCount[playerid]>=rank5Players)
        policeRanksVar[playerid] = 5;
    return true;
}
Just an example, I don't recommend using the identical same method, but it should work (untested, not even compiled)
Awesome I will try my best to learn from this example so I can create my own setup for my needs. Thank you very much for taking the time to make an example I really appreciate it! My knowledge may now grow a little further thanks to your help!
Reply
#6

no problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)