SA-MP Forums Archive
Help with code - 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: Help with code (/showthread.php?tid=286485)



Help with code - The_J0ker - 29.09.2011

Hi guys i need a little help with this code in changing it from a command to if you have an fire extinguisher or your in a fire truck you put it out.

pawn Код:
CMD:putoutfire(playerid)
{
    new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2, Float:X3, Float:Y3, Float:Z3, Float:X4, Float:Y4, Float:Z4, Float:X5, Float:Y5, Float:Z5;

    GetObjectPos(o1, X1, Y1, Z1);
    GetObjectPos(o2, X2, Y2, Z2);
    GetObjectPos(o3, X3, Y3, Z3);
    GetObjectPos(o4, X4, Y4, Z4);
    GetObjectPos(o5, X5, Y5, Z5);

    if(FireInProgress == false) return SendClientMessage(playerid, 0xFFFFFF, "ERROR: There are no fires in progress");

    if(IsPlayerInRangeOfPoint(playerid, 20.0, X1, Y1, Z1) == 0 || IsPlayerInRangeOfPoint(playerid, 20.0, X2, Y2, Z2) == 0 || IsPlayerInRangeOfPoint(playerid, 20.0, X3, Y3, Z3) == 0 || IsPlayerInRangeOfPoint(playerid, 20.0, X4, Y4, Z4) == 0 || IsPlayerInRangeOfPoint(playerid, 20.0, X5, Y5, Z5) == 0) return SendClientMessage(playerid, 0xFFFFFF, "ERROR: You are not near the fire");

    if(Reload[playerid] != false) return SendClientMessage(playerid, 0xFFFFFF, "ERROR: You need to wait before putting the fire again");
    if(GetPlayerSkin(playerid) == 277 || GetPlayerSkin(playerid) == 278 || GetPlayerSkin(playerid) == 279)
    {
        if(FireStatus < 0)
        {
            KillFire();
            return 1;
        }
        if(FireStatus < 80)
        {
            DestroyObject(o1);
            return 1;
        }
        if(FireStatus < 60)
        {
            DestroyObject(o1);
            return 1;
        }
        if(FireStatus < 40)
        {
            DestroyObject(o1);
            return 1;
        }
        if(FireStatus < 20)
        {
            DestroyObject(o1);
            return 1;
        }

        if(IsPlayerInAnyVehicle(playerid) == 1)
        {
            if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 407)
            {
                FireStatus = FireStatus - 15;
                SetTimerEx("ReloadFun", 30000, false, "i", playerid);
                Reload[playerid] = true;
                SendClientMessage(playerid, 0xFFFFFF, "You managed to put out some of the fire ((reload 30 seconds))");
            }
        }
        else if(GetPlayerWeapon(playerid) == 42)
        {
            FireStatus = FireStatus - 5;
            SetTimerEx("ReloadFun", 15000, false, "i", playerid);
            Reload[playerid] = true;
            SendClientMessage(playerid, 0xFFFFFF, "You managed to put out some of the fire ((reload 15 seconds))");
        }
        else return SendClientMessage(playerid, 0xFFFFFF, "ERROR: You must be in a Firetruck or using a fire extingusher");
    }
    else return SendClientMessage(playerid, 0xFFFFFF, "You are not in a fireman suit");
    return 1;

}



Re: Help with code - Yamoo - 29.09.2011

So you don't want a command, you want the weapons? I don't understand mate sorry.

Nineteen seconds to wait until I can post!


Re: Help with code - The_J0ker - 29.09.2011

Yes that's what I want. You have to have a fire extinguisher or been in a firetruck to put out the fires.


Re: Help with code - Saurik - 29.09.2011

Код:
CMD:putoutfire(playerid)
{
    new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2, Float:X3, Float:Y3, Float:Z3, Float:X4, Float:Y4, Float:Z4, Float:X5, Float:Y5, Float:Z5;

    GetObjectPos(o1, X1, Y1, Z1);
    GetObjectPos(o2, X2, Y2, Z2);
    GetObjectPos(o3, X3, Y3, Z3);
    GetObjectPos(o4, X4, Y4, Z4);
    GetObjectPos(o5, X5, Y5, Z5);

new vehid = GetPlayerVehicleID(playerid);
new vehicle =GetVehicleModel(vehid);
if(vehicle == 407 || GetPlayerWeapon(playerid) == 42))
{


    if(FireInProgress == false) return SendClientMessage(playerid, 0xFFFFFF, "ERROR: There are no fires in progress");
    
    if(IsPlayerInRangeOfPoint(playerid, 20.0, X1, Y1, Z1) == 0 || IsPlayerInRangeOfPoint(playerid, 20.0, X2, Y2, Z2) == 0 || IsPlayerInRangeOfPoint(playerid, 20.0, X3, Y3, Z3) == 0 || IsPlayerInRangeOfPoint(playerid, 20.0, X4, Y4, Z4) == 0 || IsPlayerInRangeOfPoint(playerid, 20.0, X5, Y5, Z5) == 0) return SendClientMessage(playerid, 0xFFFFFF, "ERROR: You are not near the fire");

    if(Reload[playerid] != false) return SendClientMessage(playerid, 0xFFFFFF, "ERROR: You need to wait before putting the fire again");
    if(GetPlayerSkin(playerid) == 277 || GetPlayerSkin(playerid) == 278 || GetPlayerSkin(playerid) == 279)
    {
        if(FireStatus < 0)
        {
            KillFire();
            return 1;
        }
        if(FireStatus < 80)
        {
            DestroyObject(o1);
            return 1;
        }
        if(FireStatus < 60)
        {
            DestroyObject(o1);
            return 1;
        }
        if(FireStatus < 40)
        {
            DestroyObject(o1);
            return 1;
        }
        if(FireStatus < 20)
        {
            DestroyObject(o1);
            return 1;
        }

        if(IsPlayerInAnyVehicle(playerid) == 1)
        {
            if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 407)
            {
                FireStatus = FireStatus - 15;
                SetTimerEx("ReloadFun", 30000, false, "i", playerid);
                Reload[playerid] = true;
                SendClientMessage(playerid, 0xFFFFFF, "You managed to put out some of the fire ((reload 30 seconds))");
            }
        }
        else if(GetPlayerWeapon(playerid) == 42)
        {
            FireStatus = FireStatus - 5;
            SetTimerEx("ReloadFun", 15000, false, "i", playerid);
            Reload[playerid] = true;
            SendClientMessage(playerid, 0xFFFFFF, "You managed to put out some of the fire ((reload 15 seconds))");
        }
        else return SendClientMessage(playerid, 0xFFFFFF, "ERROR: You must be in a Firetruck or using a fire extingusher");
    }
}
    else return SendClientMessage(playerid, 0xFFFFFF, "You are not in a fireman suit");
    return 1;

}
[/code]


Re: Help with code - The_J0ker - 29.09.2011

You have to have a fire extinguisher or been in a firetruck to put out the fires. I don't want the command just to be able to put the fire out if you have a fire extinguisher or you are in the firetruck using the water canon.


Re: Help with code - Buzzbomb - 29.09.2011

I dont think anyone has Successfully Put out any fire sources with a water cannon..


Re: Help with code - The_J0ker - 04.10.2011

Well if anyone could make it where you have to have a fire extinguisher to put out the flames instead of a command. I know it can be done I have seen video with particles that do this but aren't released.


Re: Help with code - DRIFT_HUNTER - 04.10.2011

https://sampwiki.blast.hk/wiki/GetPlayerCameraFrontVector


Re: Help with code - The_J0ker - 16.10.2011

bump i really need this