error 079: inconsistent return types (array & non-array)
#1

As the tittle says:
Код:
error 079: inconsistent return types (array & non-array)
PHP код:
stock GetPlayerGang(id)
{
    new 
string[128];
    if(
PlayerInfo[id][pGang] == 601) return string "GANG_GROVES";
    else if(
PlayerInfo[id][pGang] == 602) return string "GANG_BALLAS";
    else if(
PlayerInfo[id][pGang] = 603) return string "GANG_AZTECAS";
    else if(
PlayerInfo[id][pGang] = 604) return string "GANG_VAGOS";
    else if(
PlayerInfo[id][pGang] = 605) return string "GANG_TRIADS";
    else if(
PlayerInfo[id][pGang] = 606) return string "GANG_DA_NANG_BOYS";
    else if(
PlayerInfo[id][pGang] = 607) return string "GANG_RIFAS";
    else if(
PlayerInfo[id][pGang] = 608) return string "GANG_RUSSIAN_MAFIAS";
    else if(
PlayerInfo[id][pGang] = 609) return string "GANG_ITALIAN_MAFIAS";
    else if(
PlayerInfo[id][pGang] = 610) return string "GANG_BIKER";
    return 
string;

Reply
#2

Remove "return" before string = "..."; and keep only the last one "return string;".

Also 128 size is way too much, 20 will be fine.
Reply
#3

Код:
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(916) : warning 211: possibly unintended assignment
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(917) : warning 211: possibly unintended assignment
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(918) : warning 211: possibly unintended assignment
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(919) : warning 211: possibly unintended assignment
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(920) : warning 211: possibly unintended assignment
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(921) : warning 211: possibly unintended assignment
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(922) : warning 211: possibly unintended assignment
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(923) : warning 211: possibly unintended assignment
On each line
Reply
#4

it's because you used = in the else if statements instead of ==

Though switch is better:
PHP код:
GetPlayerGang(id)
{
    new 
string[20];
    switch (
PlayerInfo[id][pGang])
    {
        case 
601string "GANG_GROVES";
        case 
602string "GANG_BALLAS";
        case 
603string "GANG_AZTECAS";
        case 
604string "GANG_VAGOS";
        case 
605string "GANG_TRIADS";
        case 
606string "GANG_DA_NANG_BOYS";
        case 
607string "GANG_RIFAS";
        case 
608string "GANG_RUSSIAN_MAFIAS";
        case 
609string "GANG_ITALIAN_MAFIAS";
        case 
610string "GANG_BIKER";
    }
    return 
string;

Reply
#5

Код:
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(1636) : error 006: must be assigned to an array
PHP код:
ZoneInfo[i][zTeam] = GetPlayerGang(playerid); 
-_-
Reply
#6

GetPlayerGang returns a string. If zTeam is an integer, what you're trying to do will not work. If it's a string, then copy them with strcat:
pawn Код:
#if !defined strcpy
    strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif
PHP код:
strcpy(ZoneInfo[i][zTeam], GetPlayerGang(playerid), /* SIZE OF zTeam HERE */); 
Reply
#7

My gut tells me something is not quite right here. A definition is not a string. You probably have something like:
PHP код:
#define GANG_GROVES (1)
#define GANG_BALLAS (2) 
In which case you just need to return that value, not a string representation.
Reply
#8

But I don't know the size of zTeam here is the enum
PHP код:
enum eZone
{
    
Float:zMinX,
    
Float:zMinY,
    
Float:zMaxX,
    
Float:zMaxY,
    
zTeam,
    
zColor

Even there is no arrays ?!?!
Reply
#9

That's why I underlined the text before.

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
If zTeam is an integer, what you're trying to do will not work.
I told you a way of doing it if it was a string but since it isn't, returning a string is just incorrect. Vince has already told you how to do it.
Reply
#10

Anyway, I put
PHP код:
[10
beside zTeam and it worked!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)