cabbie script
#9

Here you go
If there is anything missing, please tell me

On top of your script

pawn Код:
new bool:OnDuty[MAX_PLAYERS], bool:Called[MAX_PLAYERS], fairtime_timer, pAmount[MAX_PLAYERS];
Add this at OnPlayerCommandText
pawn Код:
if(strcmp(cmdtext, "/duty", true))
{
    if(OnDuty[playerid] == true)
    {
        SendClientMessage(playerid, COLOR_WHITE, "You are now off duty!");
        SendClientMessage(playerid, COLOR_WHITE, "You will no longer receive duty messages");
        OnDuty[playerid] = false;
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "You are now on duty!");
        SendClientMessage(playerid, COLOR_WHITE, "You will receive a message when a player needs a ride");
        OnDuty[playerid] = false;
    }
    return 1;
}

if(strcmp(cmdtext, "/fare", true))
{
    // prevent spamming
    if(Called[playerid] == true)
    {
        return SendClientMessage(playerid, COLOR_WHITE, "Please wait while calling a taxi!");
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "You have called a taxi, you have to wait 2 minutes to make a new call");
        SendClientMessage(playerid, COLOR_WHITE, "[PAYMENT] You have to pay $5 each 10 minutes (game minutes)");
        SetTimerEx("CalledTaxi", 1000*60*120, false, "i", playerid);
        Called[playerid] = false;
        for(new i; i < MAX_PLAYERS; i++)
        {
            if(OnDuty[i] == true)
            {
                SendTaxiMessage(playerid, COLOR_WHITE);
            }
        }
    }
    return 1;
}
The rest speaks for itself
pawn Код:
forward CalledTaxi(playerid);
forward FairTime(playerid);

public CalledTaxi(playerid)
{
    return Called[playerid] = false;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(Called[playerid] == true)
    {
        new model = GetVehicleModel(vehicleid);
        if(model == 420 || model == 438)
        {
            fairtime_timer = SetTimerEx("FairTime", 1000*10, true, "i", playerid);
        }
    }
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(Called[playerid] == true)
    {
        new paid[128];
        format(paid, sizeof paid, "[INFO] You have paid the taxi driver %d", pAmount[playerid]);
        SendClientMessage(playerid, COLOR_WHITE, paid);
        SendClientMessage(playerid, COLOR_WHITE, "[Taxi Driver] Thank you for driving!"); // random message
        KillTimer(fairtime_timer);
        pAmount[playerid] = 0;
    }
    return 1;
}

public FairTime(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid)) return 0;
    new seat = GetPlayerVehicleSeat(playerid), Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(seat == 1 || seat == 2 || seat == 3)
    {
        GivePlayerMoney(playerid, GetPlayerMoney(playerid)-5);
        SendClientMessage(playerid, COLOR_WHITE, "[PAYMENT] You have paid the taxi driver $5");
        pAmount[playerid] += 5;
    }
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, 3, x, y, z))
        {
            new vehicle = GetPlayerVehicleID(i), model = GetVehicleModel(vehicle);
            if(model == 420 || model == 438)
            {
                GivePlayerMoney(i, GivePlayerMoney(i, GetPlayerMoney(i)+5));
                SendClientMessage(i, COLOR_WHITE, "[PAYMENT] You have been paid $5 by the passenger");
            }
        }
    }
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    pAmount[playerid] = 0;
    return 1;
}

stock SendTaxiMessage(playerid, color)
{
    new message[126], caller[MAX_PLAYER_NAME];
    GetPlayerName(playerid, caller, sizeof(caller));
    format(message, sizeof(message), "%s has called a taxi!", caller);
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(OnDuty[i] == true)
        {
                SendClientMessage(i, color, message);
        }
    }
    return 1;
}
Reply


Messages In This Thread
DELETE PLEASE - by [LHT]Bally - 11.09.2011, 15:54
Re: cabbie script - by Zonoya - 11.09.2011, 16:24
Re: cabbie script - by [LHT]Bally - 11.09.2011, 17:06
Re: cabbie script - by Kingunit - 11.09.2011, 17:16
Re: cabbie script - by Pinguinn - 11.09.2011, 17:17
Re: cabbie script - by [LHT]Bally - 11.09.2011, 17:19
Re: cabbie script - by Pinguinn - 11.09.2011, 17:39
Re: cabbie script - by [LHT]Bally - 11.09.2011, 17:44
Re: cabbie script - by Pinguinn - 11.09.2011, 17:47
Re: cabbie script - by [LHT]Bally - 11.09.2011, 17:52

Forum Jump:


Users browsing this thread: 1 Guest(s)