12.03.2014, 00:12
I was recently thinking about this, as it always confused me a bit when it came to coding (Usually as a whole, but more specifically sa-mp in this case).
If I had code like this:
Would the sequence of else statements correspond to their position?
So the first else statement would be for is the player connected, and the second one for the isplayeradmin? Or how exactly does that work?
And then another question I've always wondered, coming from making edits on scripts that are very advanced for my coding level, is this:
When I have code like this:
How does the else statement work in this situation, where does it go? Is it sequential like I think it is, or am I wrong in thinking that?
My thinking right now would be that the else for IsPlayerConnected comes first, then is a cop, then playerinfo. I'm just confused on how exactly the sequence goes because I want to restrict a privatemessage command to only admins and I don't want to mess it up in anyway.
If I had code like this:
PHP код:
if(IsPlayerConnected(playerid))
{
code blah blah blah
}
if(IsPlayerAdmin(playerid))
{
Code blah blah blah
}
So the first else statement would be for is the player connected, and the second one for the isplayeradmin? Or how exactly does that work?
And then another question I've always wondered, coming from making edits on scripts that are very advanced for my coding level, is this:
When I have code like this:
PHP код:
if(IsPlayerConnected(playerid))
{
if(IsACop(playerid)
{
if(PlayerInfo[playerid] [pRank] < 5)
{
code blah blah blah
}
My thinking right now would be that the else for IsPlayerConnected comes first, then is a cop, then playerinfo. I'm just confused on how exactly the sequence goes because I want to restrict a privatemessage command to only admins and I don't want to mess it up in anyway.