SA-MP Forums Archive
What problem??? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What problem??? (/showthread.php?tid=527936)



What problem??? - 9noober - 25.07.2014

I only can do one in "OnPlayerStateChange"

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
        new 
CarCheck GetPlayerVehicleID(playerid);
        if(
CarCheck == jcar1)
        {
        new 
PlayerName[24];
        
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
        if(
strcmp(PlayerName,"ShadowReaper",true))return RemovePlayerFromVehicle(playerid),SendClientMessage(playeridCOLOR_RED"[VEHICLE]:{FFFFFF}You can't drive this car,this car is owned by ShadowReaper.");
          {
          
SendClientMessage(playeridCOLOR_LIMEGREEN"[VEHICLE]:{FFFFFF}Welcome back to your owned car.");
        }
         if(
CarCheck == jcar2)
         {
        
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
          if(
strcmp(PlayerName,"ShadowReaper",true))return RemovePlayerFromVehicle(playerid),SendClientMessage(playeridCOLOR_RED"[VEHICLE]:{FFFFFF}You can't drive this car,this car is owned by ShadowReaper.");
        {
        
SendClientMessage(playeridCOLOR_LIMEGREEN"[VEHICLE]:{FFFFFF}Welcome back to your owned car.");
        }
        return 
1;
        }
        return 
0;




Re: What problem??? - erikhenri - 25.07.2014

What do you mean you can only do one ? Maybe you can give us some more information.


Re: What problem??? - 9noober - 25.07.2014

how to make two "if(CarCheck == carid)"


Re: What problem??? - erikhenri - 25.07.2014

to the second check you change 'if' to 'else if'


Re: What problem??? - 9noober - 25.07.2014

else if won't works it say error

Quote:

C:\Users\543shiniaopi\Desktop\gta server\samp 0.3z\filterscripts\johnbase.pwn(42) : error 029: invalid expression, assumed zero
C:\Users\543shiniaopi\Desktop\gta server\samp 0.3z\filterscripts\johnbase.pwn(42) : warning 215: expression has no effect
C:\Users\543shiniaopi\Desktop\gta server\samp 0.3z\filterscripts\johnbase.pwn(42) : error 001: expected token: ";", but found "if"
C:\Users\543shiniaopi\Desktop\gta server\samp 0.3z\filterscripts\johnbase.pwn(54) : error 030: compound statement not closed at the end of file (started at line 33)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.




Re: What problem??? - erikhenri - 25.07.2014

oops, you have to use 'else'
https://sampwiki.blast.hk/wiki/Control_Structures#else


Re: What problem??? - Virtual1ty - 25.07.2014

You never close the compound block for your first "if" check, there is your problem. You can use "if" or "elseif" depends on what you want to do.


Re: What problem??? - 9noober - 25.07.2014

if i use

Quote:

public OnPlayerStateChange(playerid, newstate, oldstate)
{
new CarCheck = GetPlayerVehicleID(playerid);
if(CarCheck == jcar1 || jcar 2)
{
new PlayerName[24];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(strcmp(PlayerName,"ShadowReaper",true))return RemovePlayerFromVehicle(playerid),SendClientMessag e(playerid, COLOR_RED, "[VEHICLE]:{FFFFFF}You can't drive this car,this car is owned by ShadowReaper.");
{
SendClientMessage(playerid, COLOR_LIMEGREEN, "[VEHICLE]:{FFFFFF}Welcome back to your owned car.");
}
return 1;
}
return 0;
}

it will send client message two times how to fix


Re: What problem??? - KayJ - 25.07.2014

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == jcar1)
        {
        new PlayerName[24];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));

        if(strcmp(PlayerName,"ShadowReaper",true))return RemovePlayerFromVehicle(playerid),SendClientMessage(playerid, COLOR_RED, "[VEHICLE]:{FFFFFF}You can't drive this car,this car is owned by ShadowReaper.");
        {
          SendClientMessage(playerid, COLOR_LIMEGREEN, "[VEHICLE]:{FFFFFF}Welcome back to your owned car.");
        }
        if(CarCheck == jcar2)
        {
            GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
            if(strcmp(PlayerName,"ShadowReaper",true))return RemovePlayerFromVehicle(playerid),SendClientMessage(playerid, COLOR_RED, "[VEHICLE]:{FFFFFF}You can't drive this car,this car is owned by ShadowReaper.");
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIMEGREEN, "[VEHICLE]:{FFFFFF}Welcome back to your owned car.");
        }
            return 1;
        }
        return 0;
}
Untested