SA-MP Forums Archive
Integer to a string. - 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: Integer to a string. (/showthread.php?tid=352102)



Integer to a string. - vIBIENNYx - 18.06.2012

Hey guys, basically, I have a player variable stored in a database. What I want to do is change that variable into a text script wise and display the text without overwriting the number variable, here's what I mean:

Here is the newbie script I am trying to create:
pawn Код:
command(n, playerid, params[])
{
    new text[128];
    if(loggedin == 0) return SendClientMessage(playerid, 0x66666666, "You must be logged in perform commands");
    if(!sscanf(params, "s[128]", text))
    {
        new Name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, Name, sizeof(Name));
        format(string, sizeof(string), "%s, %s: %s", HelperLevelToName(playerid), RemoveUnderScore(playerid), text);
        //
        return 1;
    }
    else return SendClientMessage(playerid, 0x66666666, "Usage: /n [Message]");
}

This is the empty stock that I am trying to make:
pawn Код:
stock HelperLevelToName(playerid)
{
    switch(PVar[playerid][helperlevel]
    {
        case 0:
        {
           
        }
        case 1:
        {
           
        }
        case 2:
        {
       
        }
        case 3:
        {
           
        }
    }
    return 1;
}
Both of these scripts are unfinished, but Im kind of stumped on how to proceed.


Re: Integer to a string. - HuSs3n - 18.06.2012

pawn Код:
stock HelperLevelToName(playerid)
{
    new str[20];
    switch(PVar[playerid][helperlevel]
    {
        case 0:
        {
             str = "Your_String1";
        }
        case 1:
        {
             str = "Your_String2";
        }
        case 2:
        {
             str = "Your_String3";
        }
        case 3:
        {
             str = "Your_String4";
 
        }
    }
    return str;
}



Re: Integer to a string. - vIBIENNYx - 18.06.2012

Thanks, so that would display the string on this line?

pawn Код:
format(string, sizeof(string), "%s, %s: %s", HelperLevelToName(playerid), RemoveUnderScore(playerid), text);



Re: Integer to a string. - FUNExtreme - 18.06.2012

Could you be more specific on what the outcome should be? Something like "Helper level 1 FUNExtreme" or just "Helper level 1"?...


Re: Integer to a string. - Randy More - 18.06.2012

Quote:
Originally Posted by vIBIENNYx
Посмотреть сообщение
Thanks, so that would display the string on this line?

pawn Код:
format(string, sizeof(string), "%s, %s: %s", HelperLevelToName(playerid), RemoveUnderScore(playerid), text);
It should do the trick, he gave a string/levelname depending on the variable's value, and it returns the string, also i replied to this to notify you about something, is "loggedin" a variable or some stock? because if it's a variable, it's not set for a specific player, it will be set to all players, so all will be logged in, or all are not.


Re: Integer to a string. - vIBIENNYx - 18.06.2012

Quote:
Originally Posted by Randy More
Посмотреть сообщение
It should do the trick, he gave a string/levelname depending on the variable's value, and it returns the string, also i replied to this to notify you about something, is "loggedin" a variable or some stock? because if it's a variable, it's not set for a specific player, it will be set to all players, so all will be logged in, or all are not.
It is a variable, I don't think it is specific to the player, not quite sure how.