Switch - Pawn Finaliza Sozinho
#1

pawn Код:
public obterCargo(playerid)
{
    if(gPlayer[playerid][pOrg] == GROOVE)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: return "Informante";
            case 2: return "Traficante";
            case 3: return "Gangster";
            case 4: return "Olheiro";
            case 5: return "Gerente";
            case 6: return "Dono da Boca";
            default: return "Membro";
        }
    }
    else if(gPlayer[playerid][pOrg] == BALLAS)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: return "Informante";
            case 2: return "Traficante";
            case 3: return "Gangster";
            case 4: return "Olheiro";
            case 5: return "Gerente";
            case 6: return "Dono da Boca";
            default: return "Membro";
        }
    }
    else if(gPlayer[playerid][pOrg] == PM)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: return "Cadete";
            case 2: return "Oficial";
            case 3: return "Tenente";
            case 4: return "Capitгo";
            case 5: return "Major";
            case 6: return "Comandante";
            default: return "Membro";
        }
    }
    return 1;
}
O cуdigo acima faz o meu Pawno travar. O problema й o Switch, pois eu adicionei "/* */" em todas as estrututas Switchs, e a compilaзгo ocorreu normalmente. Estou utilizando as includes da 0.3c.

Att.
Reply
#2

UP! Pra O GM Funcionar
Reply
#3

Que eu saiba, o return nгo trabalha com 'textos'.

Tente:

pawn Код:
public obterCargo(playerid,&cargo)
{
    if(gPlayer[playerid][pOrg] == GROOVE)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: {cargo="Informante";}
            case 2: {cargo="Traficante";}
            case 3: {cargo="Gangster";}
            case 4: {cargo="Olheiro";}
            case 5: {cargo="Gerente";}
            case 6: {cargo="Dono da Boca";}
            default: {cargo="Membro";}
        }
    }
    else if(gPlayer[playerid][pOrg] == BALLAS)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: {cargo="Informante";}
            case 2: {cargo="Traficante";}
            case 3: {cargo="Gangster";}
            case 4: {cargo="Olheiro";}
            case 5: {cargo="Gerente";}
            case 6: {cargo="Dono da Boca";}
            default: {cargo="Membro";}
        }
    }
    else if(gPlayer[playerid][pOrg] == PM)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: {cargo="Cadete";}
            case 2: {cargo="Oficial";}
            case 3: {cargo="Tenente";}
            case 4: {cargo="Capitгo";}
            case 5: {cargo="Major";}
            case 6: {cargo="Comandante";}
            default: {cargo="Membro";}
        }
    }
    return 1;
}
Para usar:

pawn Код:
new var[25];
obterCargo(playerid,var);
//a var: 'var' ficarб com o que ele й
Reply
#4

Compilou, mas ...

Код:
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1210) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1211) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1212) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1213) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1214) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1215) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1216) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1223) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1224) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1225) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1226) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1227) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1228) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1229) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1236) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1237) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1238) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1239) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1240) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1241) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1242) : error 006: must be assigned to an array
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


21 Errors.
=|
Reply
#5

pawn Код:
stock obterCargo(playerid, cargo)
{
    new cargo[64];
    if(gPlayer[playerid][pOrg] == GROOVE)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: { cargo="Informante";}
            case 2: { cargo="Traficante";}
            case 3: { cargo="Gangster";}
            case 4: { cargo="Olheiro";}
            case 5: { cargo="Gerente";}
            case 6: { cargo="Dono da Boca";}
            default: { cargo="Membro";}
        }
    }
    else if(gPlayer[playerid][pOrg] == BALLAS)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: {cargo="Informante";}
            case 2: {cargo="Traficante";}
            case 3: {cargo="Gangster";}
            case 4: {cargo="Olheiro";}
            case 5: {cargo="Gerente";}
            case 6: {cargo="Dono da Boca";}
            default: {cargo="Membro";}
        }
    }
    else if(gPlayer[playerid][pOrg] == PM)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: {cargo="Cadete";}
            case 2: {cargo="Oficial";}
            case 3: {cargo="Tenente";}
            case 4: {cargo="Capitгo";}
            case 5: {cargo="Major";}
            case 6: {cargo="Comandante";}
            default: {cargo="Membro";}
        }
    }
    return 1;
}
obterCargo(playerid, Grove);
Reply
#6

Tente mudar para stock.. =s

pawn Код:
stock obterCargo(playerid,&cargo)
{
    if(gPlayer[playerid][pOrg] == GROOVE)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: {cargo="Informante";}
            case 2: {cargo="Traficante";}
            case 3: {cargo="Gangster";}
            case 4: {cargo="Olheiro";}
            case 5: {cargo="Gerente";}
            case 6: {cargo="Dono da Boca";}
            default: {cargo="Membro";}
        }
    }
    else if(gPlayer[playerid][pOrg] == BALLAS)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: {cargo="Informante";}
            case 2: {cargo="Traficante";}
            case 3: {cargo="Gangster";}
            case 4: {cargo="Olheiro";}
            case 5: {cargo="Gerente";}
            case 6: {cargo="Dono da Boca";}
            default: {cargo="Membro";}
        }
    }
    else if(gPlayer[playerid][pOrg] == PM)
    {
        switch(gPlayer[playerid][pCarg])
        {
            case 1: {cargo="Cadete";}
            case 2: {cargo="Oficial";}
            case 3: {cargo="Tenente";}
            case 4: {cargo="Capitгo";}
            case 5: {cargo="Major";}
            case 6: {cargo="Comandante";}
            default: {cargo="Membro";}
        }
    }
    return 1;
}

Estou comeзando a esquecer pawn... =/
Reply
#7

Код:
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1210) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1211) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1212) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1213) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1214) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1215) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1216) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1223) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1224) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1225) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1226) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1227) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1228) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1229) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1236) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1237) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1238) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1239) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1240) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1241) : error 006: must be assigned to an array
C:\Documents and Settings\User\Desktop\serv\gamemodes\gamemode.pwn(1242) : error 006: must be assigned to an array
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


21 Errors.
Mesmo erro =|

@Edit: Eu esqueci de colocar o Stock.

Agora os erros foram Obrigado Ricop22 *-*

Qual seria a diferenзa de uma Stock para uma Public? =]
Reply
#8

Tenta o meu
Reply
#9

Obrigado Ricop *-* Nгo tinha visto a parte do Stock [Editei meu ultimo post]
Reply
#10

A stock й uma funзгo que pode ser usado para operaзхes repetitivas (strtok ou seja, sscanf). Stocks nгo sгo ultilizados como timers, etc...

Jб a public necessita de forward e й mais ultilizada para timers.
Stock se vocк nгo ultilizar, vai ficar lб sem dar o erro "symbol is never used. etc"


https://sampwiki.blast.hk/wiki/Public_functions


https://sampwiki.blast.hk/wiki/Stocks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)