Onplayerstatechange problem
#1

Hello,i've a problem.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
   if(newstate==PLAYER_STATE_PASSENGER) && if(gTeam[playerid] == TEAM_COP) return 1;
   else
   {switch(GetVehicleModel(vehicleid))
   {
   case 497,447,523,416,433,427,490,528,407,544,596,597,598,599,432,601,470,472,430,428;
   {
   new plwl = GetPlayerWantedLevel(playerid);
   plwl = GetPlayerWantedLevel(playerid);
   SetPlayerWantedLevel(playerid,plwl +4);
   new string[128];
   format(string, sizeof(string), "- CRIME - Law Enforcement Vehicle Rob - Wanted Level %d ",plwl);
   SendClientMessage(playerid,red,string);
   }
}
   return 1;
}
When a player enter in a vehicle id listed in "case",it gets +4 Wanted level,but ONLY for TEAM_CIV.

I got this errors when compiling:

Код:
C:\Documents and Settings\Symone\Desktop\Cops&Robbers\gamemodes\SF.pwn(1518) : error 029: invalid expression, assumed zero
C:\Documents and Settings\S\Desktop\Cops&Robbers\gamemodes\SF.pwn(1518) : warning 215: expression has no effect
C:\Documents and Settings\S\Desktop\Cops&Robbers\gamemodes\SF.pwn(1518) : error 001: expected token: ";", but found "if"
C:\Documents and Settings\S\Desktop\Cops&Robbers\gamemodes\SF.pwn(1520) : error 017: undefined symbol "vehicleid"
C:\Documents and Settings\S\Desktop\Cops&Robbers\gamemodes\SF.pwn(1522) : error 001: expected token: ":", but found ";"
C:\Documents and Settings\S\Desktop\Cops&Robbers\gamemodes\SF.pwn(1522) : error 036: empty statement
C:\Documents and Settings\S\Desktop\Cops&Robbers\gamemodes\SF.pwn(1531) : warning 209: function "OnPlayerStateChange" should return a value
C:\Documents and Settings\S\Desktop\Cops&Robbers\gamemodes\SF.pwn(1532) : error 010: invalid function or declaration

6 Errors.
What's wrong?Thanks.
Reply
#2

We need to know which lines the errors are on. We don't know which line 1518 is by looking at your code, do we?

Here it is anyway:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
   if(newstate == PLAYER_STATE_DRIVER && gTeam[playerid] != TEAM_COP)
    {
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
           case 497,447,523,416,433,427,490,528,407,544,596,597,598,599,432,601,470,472,430,428;
           {
               SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
               new string[64];
               format(string, sizeof(string), "- CRIME - Law Enforcement Vehicle Theft - Wanted Level %d ", GetPlayerWantedLevel(playerid));
               SendClientMessage(playerid, red, string);
            }
        }
    }
    return 1;
}
Reply
#3

Thanks,i set the code in this way:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
   if(newstate == PLAYER_STATE_DRIVER && gTeam[playerid] != TEAM_COP)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        switch(GetVehicleModel(vehicleid))
        {
           case 497,447,523,416,433,427,490,528,407,544,596,597,598,599,432,601,470,472,430,428;
           {
               new plwl = GetPlayerWantedLevel(playerid);
               plwl = GetPlayerWantedLevel(playerid);
               new string[128];
               format(string, sizeof(string), "- CRIME - Law Enforcement Vehicle Rob - Wanted Level %d ", plwl);
               SendClientMessage(playerid, red, string);
        }
    }
    return 1;
}
Now it gives me only 3 errors:

1368 : error 001: expected token: ":", but found ";" - (136 : error 036: empty statement
1377 : error 010: invalid function or declaration

Line 1368: case 497,447,523,416,433,427,490,528,407,544,596,597,59 8,599,432,601,470,472,430,428;
Line 1377: return 1;
Reply
#4

I edited my code - missed a bracket.
Reply
#5

Same problem.
Reply
#6

case 497,447,523,416,433,427,490,528,407,544,596,597,59 8,599,432,601,470,472,430,428;

should be

pawn Код:
case 497,447,523,416,433,427,490,528,407,544,596,597,598,599,432,601,470,472,430,428:
Reply
#7

The : will not work.

warning 215: expression has no effect

Because you havent closed the case.
Reply
#8

You don't close there....

pawn Код:
switch(myVar)
{//open our switch
    case 1..5:
    {//open our case
        //our code
    }//close our case
}//close our switch
Reply
#9

I dont get any error message about a non closed bracket
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)