OnPlayerRequestClass problem
#1

Код:
public OnPlayerRequestClass(playerid, classid)
{
        if(gPlayerTeam[playerid] == -1)
        {
        ShowPlayerDialog(playerid, 999, DIALOG_STYLE_LIST, "{6EF83C}Choose A Class:", "Grove Class\nBalla Class\nVagos Class\nAztecas Class\nSlut Class\nAmmunution class\nBoss Class", "Choose","");
        TogglePlayerSpectating(playerid, 1);
        SetPlayerPos(playerid,2519.8140,-1678.8607,14.8426);
        SetPlayerFacingAngle(playerid,63.1557);
        SetPlayerCameraPos(playerid,2513.6995,-1675.4047,13.5563);
        SetPlayerCameraLookAt(playerid,2519.8140,-1678.8607,14.8426);
        return 1;
        }
}
I don't like warnings, And I'm trying to fix this, what should I do?

And yeah this is the warning:
C:\Users\MARKO\Desktop\Learning\gamemodes\Test.pwn (7 : warning 209: function "OnPlayerRequestClass" should return a value
Reply
#2

The function has to return a value. Look at your code and think... does it return a value in every situation?

No, if gPlayerTeam[playerid] == -1 doesn't evaluate to true, nothing specific is returned. The function is returning an undefined value, hence the warning.
Код:
        return 1;    // either move this..
        }
        // .. here, or put another return here, if you want to return something different
}
Refer to the wiki for information on the return value: https://sampwiki.blast.hk/wiki/OnPlayerRequestClass
0 being returned will reject the spawn attempt.
Reply
#3

warning 209: function "OnPlayerRequestClass" should return a value

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
        if(gPlayerTeam[playerid] == -1)
        {
        ShowPlayerDialog(playerid, 999, DIALOG_STYLE_LIST, "{6EF83C}Choose A Class:", "Grove Class\nBalla Class\nVagos Class\nAztecas Class\nSlut Class\nAmmunution class\nBoss Class", "Choose","");
        TogglePlayerSpectating(playerid, 1);
        SetPlayerPos(playerid,2519.8140,-1678.8607,14.8426);
        SetPlayerFacingAngle(playerid,63.1557);
        SetPlayerCameraPos(playerid,2513.6995,-1675.4047,13.5563);
        SetPlayerCameraLookAt(playerid,2519.8140,-1678.8607,14.8426);
        return 1;
        }
return 1;
}
Reply
#4

Code above me will give "Loose Indentation" warning.
Use this:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
        if(gPlayerTeam[playerid] == -1)
        {
        ShowPlayerDialog(playerid, 999, DIALOG_STYLE_LIST, "{6EF83C}Choose A Class:", "Grove Class\nBalla Class\nVagos Class\nAztecas Class\nSlut Class\nAmmunution class\nBoss Class", "Choose","");
        TogglePlayerSpectating(playerid, 1);
        SetPlayerPos(playerid,2519.8140,-1678.8607,14.8426);
        SetPlayerFacingAngle(playerid,63.1557);
        SetPlayerCameraPos(playerid,2513.6995,-1675.4047,13.5563);
        SetPlayerCameraLookAt(playerid,2519.8140,-1678.8607,14.8426);
        return 1;
        }
        return 1;
}
It means you are missing the "return" in the whole public call.
Reply
#5

Loose Indentation
I have pragma thingy so it doesn't.
Reply
#6

Try this :

PHP код:
public OnPlayerRequestClass(playeridclassid)
{
        if(
gPlayerTeam[playerid] == -1)
        {
        
ShowPlayerDialog(playerid999DIALOG_STYLE_LIST"{6EF83C}Choose A Class:""Grove Class\nBalla Class\nVagos Class\nAztecas Class\nSlut Class\nAmmunution class\nBoss Class""Choose","");
        
TogglePlayerSpectating(playerid1);
        
SetPlayerPos(playerid,2519.8140,-1678.8607,14.8426);
        
SetPlayerFacingAngle(playerid,63.1557);
        
SetPlayerCameraPos(playerid,2513.6995,-1675.4047,13.5563);
        
SetPlayerCameraLookAt(playerid,2519.8140,-1678.8607,14.8426);
        }
        return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)