SREET CLEANER FILTERSCRIPT HELP(AWARDS GIVEN)
#9

Here you go, let me know if their is anything wrong since I made it in a hurry :P

You should learn to script, I had to learn the hard way since no one would help me when I would ask them to teach me :P

pawn Код:
#include <a_samp>
#include <zcmd>

#define NOTMOVING_VELO 0.000001 //Not Moving Velocity

new CleanMission[MAX_PLAYERS];
new MovingCheck[MAX_PLAYERS];

stock IsPlayerDrivingVehicle(playerid)
{
    new Float:Velo[3];
    GetVehicleVelocity(GetPlayerVehicleID(playerid), Velo[0], Velo[1], Velo[2]);
    if(Velo[0] < NOTMOVING_VELO && Velo[1] < NOTMOVING_VELO && Velo[2] < NOTMOVING_VELO) return 0;
    return 1;
}

CMD:accept(playerid, params[])
{
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 574) return SendClientMessage(playerid, 0xFAFAFAFA, "You must be in a Street Cleaning Vehicle!");
    else if(GetPVarInt(playerid, "StreetClean") == 1) return SendClientMessage(playerid, 0xFAFAFAFA, "Exit the vehicle to quit the mission!");

    TogglePlayerControllable(playerid, 1);
    SendClientMessage(playerid, 0xFAFAFAFA, "You accepted the street cleaning mission!");
    SendClientMessage(playerid, 0xFAFAFAFA, "You must clean the roads for 2 minutes!");
    SetPVarInt(playerid, "MoveWarns", 0);

    CleanMission[playerid] = SetTimerEx("StreetCleanFinish", 120000, 0, "d", playerid);
    MovingCheck[playerid] = SetTimerEx("DrivingCheck", 2000, 1, "d", playerid);
    return 1;
}

CMD:decline(playerid, params[])
{
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 574) return SendClientMessage(playerid, 0xFAFAFAFA, "You must be in a Street Cleaning Vehicle!");
    else if(GetPVarInt(playerid, "StreetClean") == 1) return SendClientMessage(playerid, 0xFAFAFAFA, "Exit the vehicle to quit the mission!");

    RemovePlayerFromVehicle(playerid);
    TogglePlayerControllable(playerid, 1);
    SendClientMessage(playerid, 0xFAFAFAFA, "You declined the street cleaning mission!");
    return 1;
}

public OnPlayerConnect(playerid)
{
    SetPVarInt(playerid, "StreetClean", 0);
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    KillTimer(MovingCheck[playerid]);
    KillTimer(CleanMission[playerid]);
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPVarInt(playerid, "StreetClean") == 0)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 574)
        {
            SendClientMessage(playerid, 0xFAFAFAFA, "Type /accept or /decline to start/exit the mission.");
            TogglePlayerControllable(playerid, 0);
            return 1;
        }
    }
    else if(newstate == PLAYER_STATE_ONFOOT && GetPVarInt(playerid, "StreetClean") == 1)
    {
        SendClientMessage(playerid, 0xFAFAFAFA, "You have left your Street Cleaning Job and earned $0!");
        TogglePlayerControllable(playerid, 1);
        KillTimer(CleanMission[playerid]);
        return 1;
    }
    return 1;
}

forward StreetCleanFinish(playerid);
public StreetCleanFinish(playerid)
{
    KillTimer(CleanMission[playerid]);
    KillTimer(MovingCheck[playerid]);
    SendClientMessage(playerid, 0xFAFAFAFA, "You successfully completed the Street Cleaning Mission!");
    SendClientMessage(playerid, 0xFAFAFAFA, "You have earned $70!");
    GivePlayerMoney(playerid, 70);
    SetPVarInt(playerid, "MoveWarns", 0);
    return 1;
}

forward DrivingCheck(playerid);
public DrivingCheck(playerid)
{
    if(IsPlayerDrivingVehicle(playerid)) return 1;

    new str[100];
    SetPVarInt(playerid, "MoveWarns", GetPVarInt(playerid, "MoveWarns")+1);
    format(str, sizeof(str), "Get your vehicle moving or the mission will end! (Warn: %d/3)", GetPVarInt(playerid, "MoveWarns"));
    SendClientMessage(playerid, 0xFAFAFAFA, str);
   
    if(GetPVarInt(playerid, "MoveWarns") > 3)
    {
        KillTimer(CleanMission[playerid]);
        KillTimer(MovingCheck[playerid]);
        SendClientMessage(playerid, 0xFAFAFAFA, "Mission Ended, you failed to keep your vehicle moving!");
        SendClientMessage(playerid, 0xFAFAFAFA, "You have left your Street Cleaning Job and earned $0!");
        SetPVarInt(playerid, "MoveWarns", 0);
        SetPVarInt(playerid, "StreetClean", 0);
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)