Score and name tittles
#1

Okay, I want to make simply when player have like 10+ score there will be his name like this:

Score 0-10: [Newbie]Name
Score 10-20: [Begginer]name
Score 20-30: [Solider]name
score 30-40: [Commander]name
etc..

So if player have 33 score (for example) his name will be [Commander] Name

BUT it wont be his name when you like press Tab or anything, only when he types.

So when you press tab his name will be (for example) Twinki
and when he chats it will be [Commander] Twinki: message
Reply
#2

Use something like this in OnPlayerText;
pawn Код:
new Rank[20];
    switch(GetPlayerScore(playerid))
    {
        case 0 .. 10: format(Rank, sizeof(Rank),"[Newbie]");
        case 11 .. 20: format(Rank, sizeof(Rank),"[Beginner]");
        //etc..
    }
    new ChatText[128], Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    format(ChatText, sizeof(ChatText),"%s %s: %s", Rank, Name, text);
    SendClientMessageToAll(-1, ChatText);
It will show the text you wanted when he talk, but name will be normal in tab list.
Reply
#3

Yeah, but how to actually make it, I am kinda noob mate.
When I try to compile that it says
Quote:

C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(379) : error 040: duplicate "case" label (value 10)
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(381) : warning 219: local variable "Name" shadows a variable at a preceding level
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(383) : error 017: undefined symbol "Text"

Reply
#4

wuups,
case 0 .. 10:
case 11 .. 20:

Rename 'Name' to something else to get rid of warning.
use small letter, text, not Text. sorry
Reply
#5

Yeah but even I rename it I get
Quote:

warning 219: local variable "Name" shadows a variable at a preceding level

Huh.. I tried changing it's name to like "tame" just for example, but still I am getting some errors. When I change it I get even more errorrs.
Reply
#6

pawn Код:
new Rank[20];
    switch(GetPlayerScore(playerid))
    {
        case 0 .. 10: format(Rank, sizeof(Rank),"[Newbie]");
        case 11 .. 20: format(Rank, sizeof(Rank),"[Beginner]");
        //etc..
    }
    new ChatText[128], Nameasd[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Nameasd, MAX_PLAYER_NAME);
    format(ChatText, sizeof(ChatText),"%s %s: %s", Rank, Nameasd, text);
    SendClientMessageToAll(-1, ChatText);
still?
Reply
#7

Well no errors on compile ^_^ let me check does it work in game
Reply
#8

Well the thing is that it works but with one little problem I get 2 messages. The original one and this one. So it goes like this:
[General]Toro_Acasta: Message
Toro_Acasta: Message
Reply
#9

Like this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new Rank[20];
    switch(GetPlayerScore(playerid))
    {
        case 0 .. 10: format(Rank, sizeof(Rank),"[Newbie]");
        case 11 .. 20: format(Rank, sizeof(Rank),"[Beginner]");
        //etc..
    }
    new ChatText[128], Nameasd[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Nameasd, MAX_PLAYER_NAME);
    format(ChatText, sizeof(ChatText),"%s %s: %s", Rank, Nameasd, text);
    SendClientMessageToAll(-1, ChatText);
    return 0; // ignore the default text and send the custom one
}
Reply
#10

Put return 0 instead of return 1, after you've send the custom message.

And a note to Richie's posts above: Don't use format to copy strings, ever! In this case, one can even do:
pawn Код:
Rank = "[Newbie]";
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)