help class error / warnings
#1

Help me please

PHP код:
C:\Users\Pгo Doce\Desktop\Mafia\gamemodes\mafia.pwn(383) : error 002only a single statement (or expressioncan follow each "case"
C:\Users\Pгo Doce\Desktop\Mafia\gamemodes\mafia.pwn(383 -- 384) : error 028invalid subscript (not an array or too many subscripts): "GetPlayerScore"
C:\Users\Pгo Doce\Desktop\Mafia\gamemodes\mafia.pwn(383 -- 385) : error 001expected token"}"but found "case"
C:\Users\Pгo Doce\Desktop\Mafia\gamemodes\mafia.pwn(383 -- 385) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

Lines

PHP код:
public OnPlayerRequestClass(playeridclassid)
{
    switch(
classid) {
        case 
.. 2Gang[playerid] = grove;
        case 
.. 5Gang[playerid] = ballas;
        case 
.. 8Gang[playerid] = vagos;
        case 
.. 11Gang[playerid] = aztecas;
         if(
GetPlayerScore(playerid) > 500)
           {
            case 
12 .. 14Gang[playerid] = cops;
        }
      }
    
SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
    
SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
    
SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384);
    
SetPlayerFacingAngle(playerid,0.0);
    return 
1;

Reply
#2

PHP код:
        case .. 11Gang[playerid] = aztecas
         if(
GetPlayerScore(playerid) > 500
           { 
            case 
12 .. 14Gang[playerid] = cops
        } 
You can't do this... That's why it's erroring out.

https://sampwiki.blast.hk/wiki/Control_Structures#case

You should try using braces ( { } ) more.

PHP код:
case 12 .. 14:
{
    if(
GetPlayerScore(playerid) > 500)
    {
        
Gang[playerid] = cops;
    }

Reply
#3

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
PHP код:
        case .. 11Gang[playerid] = aztecas
         if(
GetPlayerScore(playerid) > 500
           { 
            case 
12 .. 14Gang[playerid] = cops
        } 
You can't do this... That's why it's erroring out.

https://sampwiki.blast.hk/wiki/Control_Structures#case

You should try using braces ( { } ) more.

Код:
case 12 .. 14:
{
    if(GetPlayerScore(playerid) > 500)
    {
        Gang[playerid] = cops;
    }
}
oh thanks bro

@edit
however any User with a score lower than 500 can select the police
Reply
#4

Quote:
Originally Posted by iSoaD
Посмотреть сообщение
oh thanks bro
Now that, is something I'd like to know as well. Somewhere between OnPlayerRequestClass, and OnPlayerRequestSpawn you have to return 0 somewhere to stop them spawning.

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

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



If someone could enlighten us as to this... it would be much appreciated.
Reply
#5

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Now that, is something I'd like to know as well. Somewhere between OnPlayerRequestClass, and OnPlayerRequestSpawn you have to return 0 somewhere to stop them spawning.

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

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



If someone could enlighten us as to this... it would be much appreciated.
however any User with a score lower than 500 can select the police
Reply
#6

Currently they can, because the code runs through to the return 1 that's at the bottom.
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Currently they can, because the code runs through to the return 1 that's at the bottom.
friend, did not quite understand what you told me, my code looks like this

PHP код:
public OnPlayerRequestClass(playeridclassid)
{
    switch(
classid)
    {
        case 
.. 2Gang[playerid] = grove;
        case 
.. 5Gang[playerid] = ballas;
        case 
.. 8Gang[playerid] = vagos;
        case 
.. 11Gang[playerid] = aztecas;
          case 
12 .. 14
          
        if(
GetPlayerScore(playerid) < 500)
        {
        
Gang[playerid] = cops;
     }
    }
    
SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
    
SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
    
SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384);
    
SetPlayerFacingAngle(playerid,0.0);
    return 
1;

Reply
#8

PHP код:
public OnPlayerRequestClass(playeridclassid

    switch(
classid
    { 
        case 
.. 2Gang[playerid] = grove
        case 
.. 5Gang[playerid] = ballas
        case 
.. 8Gang[playerid] = vagos
        case 
.. 11Gang[playerid] = aztecas
        case 
12 .. 14:  
        {
           if(
GetPlayerScore(playerid) < 500
           { 
              
Gang[playerid] = cops
           } 
        }
    } 
    
SetPlayerPos(playerid,1984.4445,157.9501,55.9384); 
    
SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384); 
    
SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384); 
    
SetPlayerFacingAngle(playerid,0.0); 
    return 
1

PHP код:
public OnPlayerRequestSpawn(playerid)
{
    if(
Gang[playerid] = cops&&GetPlayerScore(playerid) < 500)
    {
        
SendClientMessage(playerid, -1"You cannot spawn.");
        return 
0;
    }
    return 
1;

You may want to look again at your code though, as if someone is sitting in the spawn window and you use Gang[playerid] totrack who is on a team, and you use a /gangchat or /department command, those who are sitting there could snoop without being spawned.
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
PHP код:
public OnPlayerRequestClass(playeridclassid

    switch(
classid
    { 
        case 
.. 2Gang[playerid] = grove
        case 
.. 5Gang[playerid] = ballas
        case 
.. 8Gang[playerid] = vagos
        case 
.. 11Gang[playerid] = aztecas
        case 
12 .. 14:  
        {
           if(
GetPlayerScore(playerid) < 500
           { 
              
Gang[playerid] = cops
           } 
        }
    } 
    
SetPlayerPos(playerid,1984.4445,157.9501,55.9384); 
    
SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384); 
    
SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384); 
    
SetPlayerFacingAngle(playerid,0.0); 
    return 
1

PHP код:
public OnPlayerRequestSpawn(playerid)
{
    if(
Gang[playerid] = cops&&GetPlayerScore(playerid) < 500)
    {
        
SendClientMessage(playerid, -1"You cannot spawn.");
        return 
0;
    }
    return 
1;

You may want to look again at your code though, as if someone is sitting in the spawn window and you use Gang[playerid] totrack who is on a team, and you use a /gangchat or /department command, those who are sitting there could snoop without being spawned.
Ah, now I understood. Thank you and sorry for having used a lot of time with my stupidity | <3

@edit
PHP код:
C:\Users\Pгo Doce\Desktop\Mafia\gamemodes\mafia.pwn(379) : warning 211possibly unintended assignment
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Warning

if(Gang[playerid] = cops&&GetPlayerScore(playerid) >= 500)
Reply
#10

PHP код:
Gang[playerid] == cops 
Mind out though too, I'm not sure the OnPlayerRequestSpawn is actually working at all. I've tried it in my script and it simply allows the spawn.

Let me know how yours goes.

-edit- Yep, my script was conflicting with it somewhere.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)