SA-MP Forums Archive
What's wrong with this? - 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: What's wrong with this? (/showthread.php?tid=313834)



What's wrong with this? - 2KY - 27.01.2012

pawn Код:
new
    p_State[MAX_PLAYERS char] = -1;
pawn Код:
stock GetPlayerScriptState(playerid)
{
    new
        p_StateName[32];
       
    switch(p_State{playerid})
    {
        case -2: {  return p_StateName = "Class Selection"; }
        case -1: {  return p_StateName = "Not Spawned";     }
        case 0: {   return p_StateName = "Spectating";      }
        case 1: {   return p_StateName = "Spawned";         }
        case 2: {   return p_StateName = "Dead";            }
    }
    return p_StateName;
}
The error I'm getting: (which I've never even seen before!)

Quote:

terror.pwn(204) : error 079: inconsistent return types (array & non-array)
terror.pwn(205) : error 079: inconsistent return types (array & non-array)
terror.pwn(206) : error 079: inconsistent return types (array & non-array)
terror.pwn(207) : error 079: inconsistent return types (array & non-array)
terror.pwn(20 : error 079: inconsistent return types (array & non-array)

Which is every line that starts with 'case', therefore I'm assuming that's the problem, but I'm not quite sure why.

EDIT: I'm an idiot. You can't return and expect it to return a value later on. Duh. Close this!


Re: What's wrong with this? - AndreT - 27.01.2012

Char-arrays cannot contain negative values as far as I know.