SA-MP Forums Archive
I can't get this to work properly - Spray system - 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: I can't get this to work properly - Spray system (/showthread.php?tid=537262)



I can't get this to work properly - Spray system - Ox1gEN - 14.09.2014

So, someone've told me how to get it to work without adding anything into it, after I added another else statement then it got fucked up, I have two of these similiar things, here are the codes:


pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE && GetPlayerWeapon(playerid) == 41)
    {
        if(IsPlayerInAnyVehicle(playerid)) return SetPlayerArmedWeapon(playerid, 0);
        else
        {
            if(ASpray[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "!?? ??? ?? ???? ?? ??є?? ??? ????? ?? ????");
            else
            {
                new Float:x, Float:y, Float:z;
                for(new i = 0; i < MAX_VEHICLES; i++)
                {
                    if(!GetVehiclePos(i, x, y, z)) continue;
                    else if(IsPlayerInRangeOfPoint(playerid, 10, x, y, z))
                    {
                        if(g_Timer == false)
                        {
                            SendClientMessage(playerid, 0xFF0000FF, "!????? ????? ?? ????, ??? ??? ????? ?? ? 15 ????? ??? ??????");
                            SetTimerEx("SprayTimer", 15000, false, "d", playerid);
                            g_Timer = true;
                        }
                        else
                        {
                            SendClientMessage(playerid, 0xFF0000FF, "!?? ??? ????? ?????, ??? ??? 15 ????? ?????");
                        }
                    }
                }
                SendClientMessage(playerid, 0xFF0000FF, "!???? ???? ??? ??? ???");
            }
        }
    }
    return 1;
}




forward SprayTimer(playerid);
public SprayTimer(playerid)
{
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        new Float:x, Float:y, Float:z;
        if(!GetVehiclePos(i, x, y, z)) continue;
        if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
        {
            ShowPlayerDialog(playerid, DIALOG_CAR_SPRAY, DIALOG_STYLE_LIST, "????? ??? ????", "??? ???\n??? ????\n??? ????\n??? ???є\n??? ????\n??? ????\n??? ????\n", "?????", "?????");
            g_Timer = false;
        }
    }
    SendClientMessage(playerid, 0xFF0000FF, "??? ?? ??? ?????! ??? ?? є???? ?? ?????? ?????? ????.");
    g_Timer = false;

    ASpray[id] = false;
    SentSpray[id] = false;
    OSpray[playerid] = false;
    return 1;
}
Don't mined the Giberish.

So bassicly here, it returns the correct thing but it also writes the thing that is outside of the loop, which I do not want it.