SA-MP Forums Archive
else if else etc. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: else if else etc. (/showthread.php?tid=190588)



else if else etc. - Haydz - 15.11.2010

Not sure what i'm doing wrong with this code.
If somebody could kindly help me out and show/tell me what i'v done wrong it would be much appreciated.

http://pastebin.com/DCq1fTKg


Re: else if else etc. - 6d - 15.11.2010

Quote:
Originally Posted by Hayden_Bruin
Посмотреть сообщение
Not sure what i'm doing wrong with this code.
If somebody could kindly help me out and show/tell me what i'v done wrong it would be much appreciated.

http://pastebin.com/DCq1fTKg
I would appreciate if you explain your problem too,
Most of the people in this forums including me has no time to compile the script
and see what errors you have, also consider some errors will happen sometimes
only to you. For Example, If i have dini.inc and you don't, and if that's you error, it will not show to me.
Also, your pastebin link is not working.

If you want good answers make a good explanation.

6d


Re: else if else etc. - Haydz - 15.11.2010

Quote:
Originally Posted by 6d
Посмотреть сообщение
I would appreciate if you explain your problem too,
Most of the people in this forums including me has no time to compile the script
and see what errors you have, also consider some errors will happen sometimes
only to you. For Example, If i have dini.inc and you don't, and if that's you error, it will not show to me.
Also, your pastebin link is not working.

If you want good answers make a good explanation.

6d
Ah i'm sorry it works perfectly fine for me, the errors were in the pastebin.

http://pastebin.com/hZaDf7Xj

The problem is not to do with includes etc just some errors i couldn't figure out because of my lack of knowledge.


Re: else if else etc. - 6d - 15.11.2010

Somehow i can't enter pastebin,
Can you put everything on [ PAWN ] [ / PAWN ] Brackets please?


Re: else if else etc. - Haydz - 15.11.2010

sure thing, thanks for helping .

pawn Код:
public OnPlayerFinishMission(playerid)
{
    SetPlayerScore(playerid, GetPlayerScore(playerid) + 3);
    new string[200];
    if (IsSmallAirCraftMission[playerid] == true) {
        new pname[24];
        new string[100];
        GetPlayerName(playerid,pname,24);
        format(string,sizeof(string), "%s completed %s in a dodo",pname,SmallAirCraftMissionRandom[MissionArrayID[playerid]][MissionName]);
        SendClientMessageToAll(COLOR_YELLOW,string);
    }
    else {
        new pname[24];
        new string[100];
        GetPlayerName(playerid,pname,24);
        format(string,sizeof(string), "%s completed %s in a Nevada",pname,CargoAirCraftMissionRandom[MissionArrayID[playerid]][MissionName]);
        SendClientMessageToAll(COLOR_YELLOW,string);
    }
(2287)else if {
(2288)  new pname[24];
        new string[100];
        GetPlayerName(playerid,pname,24);
        format(string,sizeof(string), "%s completed %s in a shamal",pname,PilotMissionRandom[MissionArrayID[playerid]][MissionName]);
        SendClientMessageToAll(COLOR_YELLOW,string);
    }
    return 1;
}
 
Errors:
 
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2275) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2282) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2287) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2287) : warning 215: expression has no effect
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2287) : error 001: expected token: ";", but found "if"
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2288) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2288) : warning 215: expression has no effect
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2288) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2288) : warning 217: loose indentation
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2288) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2288) : fatal error 107: too many error messages on one line



Re: else if else etc. - Jefff - 15.11.2010

pawn Код:
public OnPlayerFinishMission(playerid)
{
    SetPlayerScore(playerid, GetPlayerScore(playerid) + 3);
    new pname[24],string[100];
    GetPlayerName(playerid,pname,24);
    if(IsSmallAirCraftMission[playerid]) format(string,sizeof(string), "%s completed %s in a dodo",pname,SmallAirCraftMissionRandom[MissionArrayID[playerid]][MissionName]);
    else if(IsCargoAirCraftMission[playerid]) format(string,sizeof(string), "%s completed %s in a Nevada",pname,CargoAirCraftMissionRandom[MissionArrayID[playerid]][MissionName]);
    else format(string,sizeof(string), "%s completed %s in a shamal",pname,PilotMissionRandom[MissionArrayID[playerid]][MissionName]);
    SendClientMessageToAll(COLOR_YELLOW,string);
    return 1;
}



Re: else if else etc. - 6d - 15.11.2010

pawn Код:
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2275) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Hayden Bruin\Desktop\UlitmateDM\gamemodes\SAP.pwn(2282) : warning 219: local variable "string" shadows a variable at a preceding level
Those 2 are because that Variables already exist, just change the name of the variable.

pawn Код:
else if {
And this is your problem.
else if is not allowed in pawn, else if (somethinghere) is
but you need somethign inside the ( ).
For Example
pawn Код:
}else if(Team[playerid]==Team_ATC){
that one is allowed.
So yeah, compile after changing all that stuff.


Re: else if else etc. - Haydz - 16.11.2010

Awesome that works nicely, thanks to both of you for helping.