SA-MP Forums Archive
Is my OnPlayerSpawn correctly layed out? - 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: Is my OnPlayerSpawn correctly layed out? (/showthread.php?tid=493503)



Is my OnPlayerSpawn correctly layed out? - Phil_Cutcliffe - 08.02.2014

As the title sais

pawn Код:
public OnPlayerSpawn(playerid)
{
    GangZoneShowForAll(grove,COLOR_GREEN);
    GangZoneShowForAll(ballas,COLOR_PURPLE);
    GangZoneShowForAll(aztecas,COLOR_YELLOW);
    GangZoneShowForAll(rifa,COLOR_LIGHTBLUE);
    GangZoneShowForAll(triads,COLOR_NAVY);
    GangZoneShowForAll(nang,COLOR_ORANGE);
    SetPlayerMapIcon( playerid, 19, -1995.035888,91.041084,27.687500, 52, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 18, -2520.780273,-624.952392,132.785202, 30, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 17, -1605.611206,710.273315,13.867183, 30, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 16, -2026.587646,-102.059944,35.164062, 19, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 15, -2270.647460,-155.909088,35.320312, 54, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 14, -2626.641845,208.310791,4.812500, 18, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 13, -2766.420898,375.567749,6.334681, 12, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 12, -2648.894531,376.042358,6.159245, 12, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 11, -2720.941406,-320.740997,7.843750, 19, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 10, -1995.531127,25.438894,33.265567, 9, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 9, -2558.109619,663.109130,14.453125, 22, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 8, -2447.428466,821.423645,35.179687, 31, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 7, -2051.170410,450.543731,35.171875, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 6, -2524.504638,1216.099121,37.671455, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 5, 1555.500610,-1675.572998,16.195299, 30, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 4, 225.100006,1872.199951,13.699996, 23, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 3, 1459.551025,-1010.199584,26.843799, 52, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 2, 2229.847656,-1721.262329,13.561300, 54, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 20, -2489.862548,-29.063192,25.617187, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 21, -1882.312622,866.558105,35.171875, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 22, -2571.387695,246.727722,10.451436, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 23, -1694.584472,951.923095,24.890625, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 24, -2373.777099,910.194396,45.445312, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 25, -2492.464355,2363.175537,10.277318, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 26, 2244.526611,-1665.599731,15.476598, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 27, 1072.310668,-1221.302978,16.890600, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 28, 1158.464477,-1473.457519,15.796898, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 29, 1580.013549,-1845.283203,13.463000, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 30, 2396.144531,-1455.000244,24.010900, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 31, 1111.968383,-1520.968994,15.796898, 45, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 32, -1995.398071,-90.037918,36.020874, 14, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 33, -2672.226074,257.933105,4.632812, 14, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 34, 928.409973,-1353.009765,13.343798, 14, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 35, 2398.204345,-1899.198364,13.546898, 14, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 36, -1816.515258,618.194091,35.171875, 14, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 37, -2027.534423,-40.649131,38.804687, 49, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 38, -2624.598876,1412.598632,7.093750, 49, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 39, 2309.835449,-1643.285888,14.826998, 49, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 40, 1837.038330,-1681.788085,13.322898, 49, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 41, -2336.868408,-166.849899,35.554687, 10, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 42, -1912.389404,827.874206,35.226016, 10, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 43, -2355.903564,1008.118225,50.898437, 10, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 44, 810.525512,-1616.068359,13.546898, 10, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 45, -1808.754150,945.871826,24.890625, 29, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 46, -1720.947753,1359.716552,7.185316, 29, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 47, 2105.488281,-1806.288940,13.554698, 29, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 48, -2442.686767,755.410522,35.171875, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 49, -2420.156250,969.735046,45.296875, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 50, 1078.580322,-1861.912109,13.546898, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 51, 1409.661132,-1881.779052,13.546898, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 52, 1833.780639,-1842.672851,13.578100, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 53, 1928.584838,-1776.384643,13.546898, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 54, 994.370788,-1296.043701,13.546898, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 55, 1000.584472,-919.874328,42.328098, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 56, 1315.562255,-897.682189,39.578098, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 57, 1102.413574,-1458.737182,15.796898, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 58, -78.470199,-1170.115112,2.135298, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 59, -2269.540771,-29.729400,35.320301, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 60, -2032.974853,161.006301,29.046100, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 61, -2223.927490,331.970214,35.320301, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 62, -1719.810180,1274.966796,7.179698, 17, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 63, 1037.735839,-1340.730590,13.745100, 24, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 64, -2767.871582,788.856689,52.781250, 24, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 65, 2113.6999500,-2450.3999000,14.8000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 66, 2110.0996100,-1784.0000000,13.1000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 67, 1696.5000000,-1517.7998000,13.2000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 68, 1275.5000000,-1800.0000000,13.6000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 69, -210.0996100,-208.1992200,2.1000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 70, -2760.6001000,-313.2000100,6.8000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 71, -1873.8000500,-957.5999800,32.3000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 72, -352.1000100,-1425.4000200,23.4000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 73, 2508.5996100,-2110.8994100,14.3000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 74, 1766.0000000,-1070.5996100,23.8000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 75, -2129.2998000,-103.5000000,36.1000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 76, -1118.5378,-1206.5194,129.2188, 39, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 77, -1653.0000000,1291.4000200,6.9000000, 56, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 78, -2053.5000000,83.5996100,28.6000000, 20, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 79, 1178.1833,-1323.9133,14.1075, 22, 0, MAPICON_LOCAL );
    SetPlayerMapIcon( playerid, 80, 2031.7301,-1410.5670,16.9989, 22, 0, MAPICON_LOCAL );
    //TextDrawShowForPlayer(playerid, MoneySign);
    TextDrawHideForPlayer(playerid, Forums);
    new string[256];
    if(CaptureOk == drugpointsf && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 20)
    {
        GangZoneFlashForPlayer(playerid,drugzonesf,COLOR_RED);
        SendClientMessage(playerid, COLOR_ORANGE, "[San Fierro Drug Zone] - This Zone is now available to capture!");
    }
    if(CaptureOk == drugpointls && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 20)
    {
        GangZoneFlashForPlayer(playerid,drugzonels,COLOR_RED);
        SendClientMessage(playerid, COLOR_ORANGE, "[Los Santos Drug Zone] - This Zone is now available to capture!");
    }
    if(CaptureOk == matrunsf && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 20)
    {
        GangZoneFlashForPlayer(playerid,matzonesf,COLOR_RED);
        SendClientMessage(playerid, COLOR_ORANGE, "[San Fierro Weapon Zone] - This Zone is now available to capture!");
    }
    if(CaptureOk == matrunls && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 20)
    {
        GangZoneFlashForPlayer(playerid,matzonels,COLOR_RED);
        SendClientMessage(playerid, COLOR_ORANGE, "[Los Santos Weapon Zone] - This Zone is now available to capture!");
    }
    if(PlayerInfo[playerid][pInsideInterior] == 1 && JustDied[playerid] == 0 && PlayerInfo[playerid][pDeadAlready] == 0 && PlayerInfo[playerid][pDead] == 0)
    {
        SetTimerEx("InteriorFreeze2", 100, false, "i", playerid);
    }
    if(FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 20)
    {
        GangZoneShowForPlayer(playerid, drugzonesf, COLOR_WHITE);
        GangZoneShowForPlayer(playerid, drugzonels, COLOR_WHITE);
        GangZoneShowForPlayer(playerid, matzonesf, COLOR_WHITE);
        GangZoneShowForPlayer(playerid, matzonels, COLOR_WHITE);
    }
    if(PlayerInfo[playerid][pTutorial] == 0)
    {
        SetTimerEx("Cam1", 1000, false, "i", playerid);
        return 1;
    }
    if(PlayerInfo[playerid][pDead] == 1)
    {
        SetTimerEx("DeadNow", 1000, false, "i", playerid);
        return 1;
    }
    if(PlayerInfo[playerid][pDeadAlready] == 1)
    {
        SetTimerEx("DeadNow", 1000, false, "i", playerid);
        return 1;
    }
    if(JustDied[playerid] == 1 && PlayerInfo[playerid][pDeadAlready] == 0)
    {
        if(PlayerInfo[playerid][pPrison] == 0)
        {
            SendClientMessage(playerid, COLOR_BLUE, "----------------------------------------------------------");
            SendClientMessage(playerid, COLOR_BLUE, "You are heavily injured and will soon become unconscious.");
            SendClientMessage(playerid, COLOR_BLUE, "If you do become unconscious you will be taken to the nearest Hospital.");
            SendClientMessage(playerid, COLOR_BLUE, "You can wait for an EMT to find you or /giveup and go straight to Hospital.");
            SendClientMessage(playerid, COLOR_BLUE, "----------------------------------------------------------");
            SetPlayerPos(playerid, deadx[playerid], deady[playerid], deadz[playerid]);
            SetPlayerInterior(playerid, DeadInt[playerid]);
            SetPlayerVirtualWorld(playerid, DeadWorld[playerid]);
            SetPlayerCameraPos(playerid, deadx[playerid], deady[playerid], deadz[playerid]+5);
            SetPlayerCameraLookAt(playerid, deadx[playerid], deady[playerid], deadz[playerid]);
            ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
            SetTimerEx("FallPlayer", 1000, 0, "d", playerid);
            PRHealth[playerid] = SetTimerEx("HealthTimer", 1000,1,"i",playerid);
            return 1;
        }
        if(PlayerInfo[playerid][pPrison] == 1)
        {
            JustDied[playerid] = 0;
            TogglePlayerControllable(playerid, 1);
            ClearAnimations(playerid);
            SetCameraBehindPlayer(playerid);
            SetPlayerHealth(playerid, 100);
            return 1;
        }
    }
    format(string, sizeof(string), "MOTD - %s", MOTD);
    SendClientMessage(playerid, COLOR_SPRINGGREEN, string);
    if(PlayerInfo[playerid][pDisease] == LungCancer)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You're having trouble breathing... (( Lung Cancer ))");
        SetTimerEx("Cough", 60000, 1, "d", playerid);
    }
    return 1;
}



Re: Is my OnPlayerSpawn correctly layed out? - CuervO - 08.02.2014

Well, is there any problem at all with it?

It seems correctly layed though, except from the first six lines, you're showing the Gangzone to everyone when a player respawns, shouldn't it be that it shows the gangzone to the player that has respawned?


Re: Is my OnPlayerSpawn correctly layed out? - Phil_Cutcliffe - 08.02.2014

Quote:
Originally Posted by CuervO
Посмотреть сообщение
Well, is there any problem at all with it?

It seems correctly layed though, except from the first six lines, you're showing the Gangzone to everyone when a player respawns, shouldn't it be that it shows the gangzone to the player that has respawned?
Indeed good call! I just wanted to know if that was layed out correctly. There are a couple of problems but obviously they don't originate from there. Cheers pal +repped. Thanks for taking a look.

EDIT: Will give rep when it lets me.. I'm getting the message lol -_-


Re: Is my OnPlayerSpawn correctly layed out? - dadh - 08.02.2014

I'm not sure if this is a legit notice, but in the first four if statements, why you didn't use "else if".
With your current code it will have to check for the four cases, although CaptureOK must have only one value.


Re: Is my OnPlayerSpawn correctly layed out? - CuervO - 08.02.2014

Quote:
Originally Posted by dadh
Посмотреть сообщение
I'm not sure if this is a legit notice, but in the first four if statements, why you didn't use "else if".
With your current code it will have to check for the four cases, although CaptureOK must have only one value.
True, you could optimize this the following way:

pawn Код:
if(FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 20)
{
    if(CaptureOk == drugpointsf)
    {
        GangZoneFlashForPlayer(playerid,drugzonesf,COLOR_RED);
        SendClientMessage(playerid, COLOR_ORANGE, "[San Fierro Drug Zone] - This Zone is now available to capture!");
    }
    else if(CaptureOk == drugpointls)
    {
        GangZoneFlashForPlayer(playerid,drugzonels,COLOR_RED);
        SendClientMessage(playerid, COLOR_ORANGE, "[Los Santos Drug Zone] - This Zone is now available to capture!");
    }
    else if(CaptureOk == matrunsf)
    {
        GangZoneFlashForPlayer(playerid,matzonesf,COLOR_RED);
        SendClientMessage(playerid, COLOR_ORANGE, "[San Fierro Weapon Zone] - This Zone is now available to capture!");
    }
    else if(CaptureOk == matrunls)
    {
        GangZoneFlashForPlayer(playerid,matzonels,COLOR_RED);
        SendClientMessage(playerid, COLOR_ORANGE, "[Los Santos Weapon Zone] - This Zone is now available to capture!");
    }
}
Or using switch statements (even faster), either ways it's the same; Your way of writting it is not wrong either, it will still work.