SA-MP Forums Archive
String problems - 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: String problems (/showthread.php?tid=290295)



String problems - Jack_Leslie - 15.10.2011

I have this string:
pawn Код:
format(string, sizeof(string), "Your origin is %s.", GetPlayerOrigin(playerid));
It's meant to switch between the enum values (which are right, I debugged them) and output the string but it doesn't. here's the getplayerorigin:

pawn Код:
public GetPlayerOrigin(playerid)
{
    new string[126];
    switch(PlayerInfo[playerid][Origin])
    {
        case 5: string = "Russia";
        case 4: string = "Africa";
        case 3: string = "Australian";
        case 2: string = "Europe";
        case 1: string = "America";
        case 0: string = "No Origin Specified";
        default: string = "None";
    }
    return 1;
}



Re: String problems - AeroBlast - 15.10.2011

I think that this would work:

pawn Код:
public GetPlayerOrigin(playerid)
{
    new string[126];
    switch(PlayerInfo[playerid][Origin])
    {
        case 5: string = "Russia";
        case 4: string = "Africa";
        case 3: string = "Australian";
        case 2: string = "Europe";
        case 1: string = "America";
        case 0: string = "No Origin Specified";
        default: string = "None";
        return string;
    }
    return 1;
}
Again, I don't know if this works.


Re: String problems - PrawkC - 15.10.2011

pawn Код:
stock GetPlayerOrigin(playerid)
{
    new string[126];
    switch(PlayerInfo[playerid][Origin])
    {
        case 5: string = "Russia";
        case 4: string = "Africa";
        case 3: string = "Australian";
        case 2: string = "Europe";
        case 1: string = "America";
        case 0: string = "No Origin Specified";
        default: string = "None";
    }
    return string;
}
Must be a stock, a public cannot return a string.


Re: String problems - Jack_Leslie - 15.10.2011

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
pawn Код:
stock GetPlayerOrigin(playerid)
{
    new string[126];
    switch(PlayerInfo[playerid][Origin])
    {
        case 5: string = "Russia";
        case 4: string = "Africa";
        case 3: string = "Australian";
        case 2: string = "Europe";
        case 1: string = "America";
        case 0: string = "No Origin Specified";
        default: string = "None";
    }
    return string;
}
Must be a stock, a public cannot return a string.
Thank you handsome sir.


Re: String problems - Ash. - 15.10.2011

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
Thank you handsome sir.
Does that actually work correctly?
I'm sure assigning strings to variables cannot be done through the equals operator...

Could be having a stupid moment though...


Re: String problems - Jack_Leslie - 15.10.2011

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Does that actually work correctly?
I'm sure assigning strings to variables cannot be done through the equals operator...

Could be having a stupid moment though...
Yes it did work.


Re: String problems - Ash. - 15.10.2011

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
Yes it did work.
Definitely a stupid moment, I guess! Sorry!


Re: String problems - GrimR - 15.10.2011

I agree though funky, I always got errors when doing this, I even posted about it....

Also you were doing return 1;, so it wouldn't be passing a string back anyway lol. But I see you have it solved now.