String problems
#1

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;
}
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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...
Reply
#6

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.
Reply
#7

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)