Rank in string help...
#1

**DELETE
Reply
#2

Increase the string size from:
pawn Код:
new string[60];
//TO
new string[128];
Reply
#3

**DELETE
Reply
#4

**DELETE
Reply
#5

pawn Код:
forward Rank(playerid);
public Rank(playerid)
{
    new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    if(Class[playerid] == TRUCKER_CLASS)
    {
        if (GetPlayerScore(playerid) >= 0 && GetPlayerScore(playerid) <= 100)
        {
            format(string,sizeof(string),"%s Has Joined Trucker Class (Newbie Trucker)", pName);
        }
        if (GetPlayerScore(playerid) >= 100)
        {
            format(string,sizeof(string),"%s Has Joined Trucker Class (Newbie2 Trucker)", pName);
        }
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(Class[playerid] == TRUCKER_CLASS)
    {
        if (GetPlayerScore(playerid) >= 0 && GetPlayerScore(playerid) <= 100)
        {
            // Do something here
            SetPlayerHealth(playerid, 50); // This is example
        }
        if (GetPlayerScore(playerid) >= 100)
        {
            // Do something here
            SetPlayerHealth(playerid, 75); // This is example
        }
    }
    return 1;
}
Try to do it like this
Reply
#6

Otherwise this is a nice function:
pawn Код:
stock getRankName(playerid)
{
    new output[75];
    if (GetPlayerScore(playerid) >= 0 && GetPlayerScore(playerid) < 100) format(output, 75, "Newbie trucker");
    else if(GetPlayerScore(playerid) >= 100) format(output, 75, "Newbie2 trucker");
    else format(output, 75, "Newbie-1 trucker"); //When score is lower then 0.. you might not need this
    return output;
}
Then in order to use it:
pawn Код:
public OnPlayerSpawn(playerid)
{
    new pName[MAX_PLAYER_NAME], Rank[MAX_PLAYERS];
    new string[128]; //Sorry for increasing this size :P
    if (Class[playerid] == TRUCKER_CLASS)
    {
        format(string, 128, "%s has joined trucker class (%s)", pName, getRankName(playerid));
        SendClientMessageToAll(0xFFFFFFAA, string); //Send the message to everyone instead of only the spawned player!
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)