Rank system newbie question
#1

hi,
id like to script a rank system: as soon as someone has 20 kills he is promoted to noob killer, with 100 kills hell be a grammy shooter and so on.
Is it possible to script it like that:

pawn Код:
{
    switch(kills[playerid])
    {
        case 0:
        {
            if(kills[playerid] == 20)
            {
                Rank[playerid]++;
                SendClientMessage(playerid,0x78FF6CAA,"Congratulations! You promoted to rank noob shooter, +$200!");
                GivePlayerMoney(playerid,200);
            }
        }
        case 1:
        {
            if(kills[playerid] == 100)
            {
                Rank[playerid]++;
                SendClientMessage(playerid,0x78FF6CAA,"Congratulations! You promoted to grammy shooter, and earned $1200!");
                GivePlayerMoney(playerid,1200);
            }
        }
        case 2:
        {
            if(kills[playerid] == 500)
            {
                Rank[playerid]++;
                SendClientMessage(playerid,0x78FF6CAA,"Congratulations! You promoted to what ever, and earned $2300!");
                GivePlayerMoney(playerid,2300);
            }
        }

    }
}



if(strcmp(cmdtext,"/stats",true)==0)
{

new str[50];
format(str,sizeof(str),"Your rank is %d",GetPlayerRank(playerid));
SendClientMessage(playerid,0xFFFF00AA,str);

return 1;
}



stock GetPlayerRank(playerid)
{
    return Rank[playerid];
}
If its possible with this code somehow, where do i have to paste it in and what do i have to add??

regards.
Reply
#2

Well, the 'switch-case' system works like this:

pawn Код:
switch(variable)
{
  case 0:
  {
    print("Hi!");
  }
  case 1:
  {
    SendRconCommand("gmx");
  case 2: return 1;
}
]

This means that if the variable is equal to '0', SA-MP will print 'hi'.
If the variable is equal to 1, it'll GMX the server.
And if the variable is equal to 2, it'll simply return 1.

So, to your code, here's an example (And you do the rest ):

pawn Код:
switch(kills[playerid])
    {
        case 20: //Gets called if the player has got 20 kills.
        {
                Rank[playerid]++;
                SendClientMessage(playerid,0x78FF6CAA,"Congratulations! You promoted to rank noob shooter, +$200!");
                GivePlayerMoney(playerid,200);
        }

Got it? Now do the rest !
Reply
#3

haha, yeah i have and i want to do the rest but

if i want to display my rank with /stats (pls see my prevous post)
i have to set up the rank names somewhere rigth?
can i do it also with the case system somehow?
And where do i have to write it down. (onplayerconnect?)

thx very much for ur help

BTW: lol The Turtly Turtle
how did u come up with that??!!
Reply
#4

hi,
thx for ur help i got it now
thx
Reply
#5

mhhh, it looks pretty good but it just doesnt promote me to the next rank, Why

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{

     new string[256];

     if(kills[playerid] == 30)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Baby Killer and now has %d kills!!", string, kills[playerid] );
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 1;
    }
         else if(kills[playerid] == 100)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Shooter and now has %d kills!!", string, kills[playerid]);
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 2;
    }
         else if(kills[playerid] == 250)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Accurate Shooter and now has %d kills!!", string, kills[playerid]);
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 3;
    }



     return 1;
}


under onplayercommandtext


if (strcmp("/ranki", cmdtext, true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {   SendClientMessage(playerid, 0xFFFF00AA, "///////////////////////////////////////////////////");
            new rankid = pRank[playerid];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            new rank[20];
            if(pRank[playerid] == 0) { rank = "Newbie"; }
            else if(pRank[playerid] == 1) { rank = "Baby Killer"; }
            else if(pRank[playerid] == 2) { rank = "Shooter"; }
            else if(pRank[playerid] == 3) { rank = "Accurate Shooter"; }
            else if(pRank[playerid] == 4) { rank = "Deadly Shooter"; }
            else if(pRank[playerid] == 5) { rank = "Hitman"; }
            else if(pRank[playerid] == 6) { rank = "Insane Killer"; }
            else if(pRank[playerid] == 7) { rank = "Disturbed Butcher"; }
            else if(pRank[playerid] == 8) { rank = "Warrior Of Death"; }
            else if(pRank[playerid] == 9) { rank = "Immortal Warrior"; }
            new s[50];
            format(s,sizeof(s), "Your Rank: %s | Rank number: %d",rank,rankid);
            SendClientMessage(playerid, 0xFFFF00AA,s);
            SendClientMessage(playerid, 0xFFFF00AA, "///////////////////////////////////////////////////");

        }
        return 1;
}

I hope that some pro scripters are able to help me.
Reply
#6

Код:
public OnPlayerDeath(playerid, killerid, reason)
{

     new string[256];

     if(kills[playerid] == 30) 
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Baby Killer and now has %d kills!!", string, kills[playerid] );
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 1;
    }
         else if(kills[playerid] == 100)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Shooter and now has %d kills!!", string, kills[playerid]);
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 2;
    }
         else if(kills[playerid] == 250)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Accurate Shooter and now has %d kills!!", string, kills[playerid]);
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 3;
    }
	format(string,sizeof(string),"Rank: %s",Ranks[pRank[killerid]]);
	TextDrawSetString(Rank[killerid],string);
}
return 1;
}
Thats what i got... check if it works.
Reply
#7

You need a save system.
Reply
#8

try this
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{

     new string[256];

     if(kills[killerid] == 30)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Baby Killer and now has %d kills!!", string, kills[playerid] );
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 1;
    }
         else if(kills[killerid] == 100)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Shooter and now has %d kills!!", string, kills[playerid]);
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 2;
    }
         else if(kills[killerid] == 250)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Accurate Shooter and now has %d kills!!", string, kills[playerid]);
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 3;
    }



     return 1;
}
Reply
#9

hi, thx for ur answers.

my problem is, as soon as i get 20 kills it shows me (clientmessage) that ive been promoted to the next rank, but if i type in /ranki, the rankinformation doesnt change. It always says Rank: Newbie / Ranknumber: 0. but it should say Baby Killer and 1 (rank,rankid).

pls help, i really dont know what do do.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
     new string[256];

     if(kills[killerid] == 20) //
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Baby Killer and now has %d kills!!", string, kills[killerid] );
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 1;
    }
         else if(kills[killerid] == 100)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Shooter and now has %d kills!!", string, kills[killerid]);
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 2;
    }
         else if(kills[killerid] == 250)
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), "%s has been promoted to Accurate Shooter and now has %d kills!!", string, kills[killerid]);
        SendClientMessageToAll(0x993300AA, string);
        pRank[playerid] = 3;
    }
        }
        return 1;




public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/ranki", cmdtext, true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {   SendClientMessage(playerid, 0xFFFF00AA, "///////////////////////////////////////////////////");
            new rankid = pRank[playerid];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            new rank[20];
            if(pRank[playerid] == 0) { rank = "Newbie"; }
            else if(pRank[playerid] == 1) { rank = "Baby Killer"; }
            else if(pRank[playerid] == 2) { rank = "Shooter"; }
            else if(pRank[playerid] == 3) { rank = "Accurate Shooter"; }
            else if(pRank[playerid] == 4) { rank = "Deadly Shooter"; }
            else if(pRank[playerid] == 5) { rank = "Hitman"; }
            else if(pRank[playerid] == 6) { rank = "Insane Killer"; }
            else if(pRank[playerid] == 7) { rank = "Disturbed Butcher"; }
            else if(pRank[playerid] == 8) { rank = "Warrior Of Death"; }
            else if(pRank[playerid] == 9) { rank = "Immortal Warrior"; }
            new s[50];
            format(s,sizeof(s), "Your Rank: %s | Rank number: %d",rank,rankid);
            SendClientMessage(playerid, 0xFFFF00AA,s);
            SendClientMessage(playerid, 0xFFFF00AA, "///////////////////////////////////////////////////");

        }
        return 1;
}
Reply
#10

anybody can help me with this??
please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)