SA-MP Forums Archive
Reading only first 3 functions? - 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: Reading only first 3 functions? (/showthread.php?tid=580529)



Reading only first 3 functions? - Mouiz - 06.07.2015

I have made a public function

Код:
public OnPlayerSpawn(playerid)
{
    PlayerPlaySound(playerid,1063,0.0,0.0,0.0);
    if(God[playerid] == 1) return SetPlayerHealth(playerid, 99999);
   	else if(PlayerInfo[playerid][Jail] == 1)
	{
	    SetPlayerPos(playerid, 198.1810,174.9016,1003.0234);
		SetPlayerFacingAngle(playerid, 0.6133);
		ResetPlayerWeapons(playerid);
	    SetPlayerInterior(playerid, 3);
	    SetPlayerVirtualWorld(playerid, 50);
		return 1;
	}
    else if(PlayerInfo[playerid][pVip] == 1) return SetPlayerArmour(playerid, 100);
	else if(fr[playerid] == 1)
	{
    SetPlayerVirtualWorld(playerid, 0);
    SetPlayerInterior(playerid, 0);
    SetPlayerPos(playerid, -1680.1483,706.0532,30.6016);
    SetPlayerFacingAngle(playerid, 90.9011);
    fr[playerid] = 1;
    if(PlayerInfo[playerid][Jail] == 0)
    {
    GameTextForPlayer(playerid,"~g~type ~w~/fr ~g~to change the mode",5000,1);
    }
	else if(indm[playerid] == 1)
	{
	SetPlayerTeam(playerid, -1);
    SetPlayerPos(playerid, 1302.519897,-1.787510,1001.028259);
    SetPlayerInterior(playerid, 18);
    SetPlayerVirtualWorld(playerid, 2);
    ResetPlayerWeapons(playerid);
	GivePlayerWeapon(playerid, 24, 999999);
	}
	else if(indm[playerid] == 2)
	{
	SetPlayerTeam(playerid, -1);
    SetPlayerPos(playerid, 2215.454833,-1147.475585,1025.796875);
    SetPlayerInterior(playerid, 15);
    SetPlayerVirtualWorld(playerid, 1);
    ResetPlayerWeapons(playerid);
	GivePlayerWeapon(playerid, 34, 999999);
	}
    }
	else if(PlayerInfo[playerid][pMuted] == 1)
	{
		MuteTimer[playerid] = SetTimerEx("OnPlayerUnmute", PlayerInfo[playerid][MuteTime], false, "d", playerid);
		return 0;
	}
    IsJumping[playerid] = 0;
	TextDrawShowForPlayer(playerid, InfoTextdraw);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    SetPlayerWeatherEx(playerid,PlayerInfo[playerid][pWeather]);
	return 1;

}
But when i test it in-game,i only reads these first 3 functions:

Код:
    if(God[playerid] == 1) return SetPlayerHealth(playerid, 99999);
   	else if(PlayerInfo[playerid][Jail] == 1)
	{
	    SetPlayerPos(playerid, 198.1810,174.9016,1003.0234);
		SetPlayerFacingAngle(playerid, 0.6133);
		ResetPlayerWeapons(playerid);
	    SetPlayerInterior(playerid, 3);
	    SetPlayerVirtualWorld(playerid, 50);
		return 1;
	}
    else if(PlayerInfo[playerid][pVip] == 1) return SetPlayerArmour(playerid, 100);
Help please!



Re: Reading only first 3 functions? - Threshold - 06.07.2015

pawn Код:
public OnPlayerSpawn(playerid)
{
    PlayerPlaySound(playerid, 1063, 0.0, 0.0, 0.0);
    if(God[playerid] == 1) SetPlayerHealth(playerid, 99999);
    if(PlayerInfo[playerid][pVip] == 1) SetPlayerArmour(playerid, 100.0);
    if(!PlayerInfo[playerid][Jail])
    {
        GameTextForPlayer(playerid, "~g~type ~w~/fr ~g~to change the mode",5000,1);
        if(fr[playerid] == 1)
        {
            SetPlayerVirtualWorld(playerid, 0);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1680.1483,706.0532,30.6016);
            SetPlayerFacingAngle(playerid, 90.9011);
        }
        else if(indm[playerid] == 1)
        {
            SetPlayerTeam(playerid, NO_TEAM);
            SetPlayerPos(playerid, 1302.519897,-1.787510,1001.028259);
            SetPlayerInterior(playerid, 18);
            SetPlayerVirtualWorld(playerid, 2);
            ResetPlayerWeapons(playerid);
            GivePlayerWeapon(playerid, 24, 999999);
        }
        else if(indm[playerid] == 2)
        {
            SetPlayerTeam(playerid, NO_TEAM);
            SetPlayerPos(playerid, 2215.454833,-1147.475585,1025.796875);
            SetPlayerInterior(playerid, 15);
            SetPlayerVirtualWorld(playerid, 1);
            ResetPlayerWeapons(playerid);
            GivePlayerWeapon(playerid, 34, 999999);
        }
    }
    else
    {
        SetPlayerInterior(playerid, 3);
        SetPlayerPos(playerid, 198.1810, 174.9016, 1003.0234);
        SetPlayerFacingAngle(playerid, 0.6133);
        ResetPlayerWeapons(playerid);
        SetPlayerVirtualWorld(playerid, 50);
    }
    if(PlayerInfo[playerid][pMuted] == 1) MuteTimer[playerid] = SetTimerEx("OnPlayerUnmute", PlayerInfo[playerid][MuteTime], false, "d", playerid);
    IsJumping[playerid] = 0;
    TextDrawShowForPlayer(playerid, InfoTextdraw);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    SetPlayerWeatherEx(playerid, PlayerInfo[playerid][pWeather]);
    return 1;
}
You keep using 'return' in the middle of your statements. Return will break the code and prevent it from continuing. So if you meet any of the conditions in the 'if' statement, your code will end immediately after that.

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


Re: Reading only first 3 functions? - Mouiz - 06.07.2015

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
public OnPlayerSpawn(playerid)
{
    PlayerPlaySound(playerid, 1063, 0.0, 0.0, 0.0);
    if(God[playerid] == 1) SetPlayerHealth(playerid, 99999);
    if(PlayerInfo[playerid][pVip] == 1) SetPlayerArmour(playerid, 100.0);
    if(!PlayerInfo[playerid][Jail])
    {
        GameTextForPlayer(playerid, "~g~type ~w~/fr ~g~to change the mode",5000,1);
        if(fr[playerid] == 1)
        {
            SetPlayerVirtualWorld(playerid, 0);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1680.1483,706.0532,30.6016);
            SetPlayerFacingAngle(playerid, 90.9011);
        }
        else if(indm[playerid] == 1)
        {
            SetPlayerTeam(playerid, NO_TEAM);
            SetPlayerPos(playerid, 1302.519897,-1.787510,1001.028259);
            SetPlayerInterior(playerid, 18);
            SetPlayerVirtualWorld(playerid, 2);
            ResetPlayerWeapons(playerid);
            GivePlayerWeapon(playerid, 24, 999999);
        }
        else if(indm[playerid] == 2)
        {
            SetPlayerTeam(playerid, NO_TEAM);
            SetPlayerPos(playerid, 2215.454833,-1147.475585,1025.796875);
            SetPlayerInterior(playerid, 15);
            SetPlayerVirtualWorld(playerid, 1);
            ResetPlayerWeapons(playerid);
            GivePlayerWeapon(playerid, 34, 999999);
        }
    }
    else
    {
        SetPlayerInterior(playerid, 3);
        SetPlayerPos(playerid, 198.1810, 174.9016, 1003.0234);
        SetPlayerFacingAngle(playerid, 0.6133);
        ResetPlayerWeapons(playerid);
        SetPlayerVirtualWorld(playerid, 50);
    }
    if(PlayerInfo[playerid][pMuted] == 1) MuteTimer[playerid] = SetTimerEx("OnPlayerUnmute", PlayerInfo[playerid][MuteTime], false, "d", playerid);
    IsJumping[playerid] = 0;
    TextDrawShowForPlayer(playerid, InfoTextdraw);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    SetPlayerWeatherEx(playerid, PlayerInfo[playerid][pWeather]);
    return 1;
}
You keep using 'return' in the middle of your statements. Return will break the code and prevent it from continuing. So if you meet any of the conditions in the 'if' statement, your code will end immediately after that.

https://sampwiki.blast.hk/wiki/Control_Structures#return
Thanks,+Rep