SA-MP Forums Archive
Rank in string help... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Rank in string help... (/showthread.php?tid=436157)



**DELETE** - Pettersen - 10.05.2013

**DELETE


Re: Rank in string help... - Lordzy - 10.05.2013

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



**DELETE** - Pettersen - 10.05.2013

**DELETE


**DELETE** - Pettersen - 10.05.2013

**DELETE


Re: Rank in string help... - RenSoprano - 10.05.2013

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


Re: Rank in string help... - Kwarde - 10.05.2013

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;
}