Adding a 2 minute timer to /repair?
#1

i want to add 2 minute timer in my '/repair' after the 2 minute timer their will be

'Mechanic Engineer %s has sucessfully repaired %s's vehicle engine'

and the owner of the vehicle engine will give the Mechanic Engineer, $5,000. also how to check if the mechanic engineer is riding the vehicle of selected id, if player is not in selected id vehicle he cannot fix the engine.

CODE:

pawn Код:
CMD:repair(playerid, params[])
{
    new string[120], id;
    if(pInfo[playerid][JobMember] == 2 || pInfo[playerid][JobLeader] == 2)
    {
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /repair [playerid]");
        if(IsPlayerInAnyVehicle(playerid)) {
            if(GetPlayerMoney(id) > 5000) return SendClientMessage(id, COLOR_GREY, "You do not have enough money to pay the mechanic engineer!");
            format(string, sizeof(string), "Mechanic Engineer %s is fixng %s's vehicle engine...", GetName(playerid), GetName(id));
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string, sizeof(string), "Mechanic Engineer %s will gonna fix your vehicle engine...", GetName(playerid));
            SendClientMessage(id, COLOR_YELLOW, string);
            format(string, sizeof(string), "You fixing %s's vehicle engine", GetName(id));
            SendClientMessage(playerid, COLOR_YELLOW, string);
            SetVehicleHealth(GetPlayerVehicleID(id), 1000);
            RepairVehicle(GetPlayerVehicleID(id));
            format(string, sizeof(string), "Mechanic Engineer %s has sucessfully fix %s's vehicle engine", GetName(playerid), GetName(id));
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string, sizeof(string), "Mechanic Engineer %s has fix your vehicle engine, you will pay 5,000$", GetName(playerid));
            SendClientMessage(id, COLOR_YELLOW, string);
            format(string, sizeof(string), "You sucessfully fix %s's vehicle engine, he/she pays you 5,000$", GetName(id));
            SendClientMessage(playerid, COLOR_YELLOW, string);
            GivePlayerMoney(playerid, 5000);
            GivePlayerMoney(id, -5000);
        } else {
            SendClientMessage(playerid, COLOR_GREY, "  You are not Mechanic Engineer!  ");
        }
    }
    return 1;
}
Reply
#2

A simple suggestion. Make two Stocks with params playerid and giveplayerid (Something else too). One stock for the request to fix the vehicle and the things will done in it (Use SetTimerEx for the statements you want to set the timer for)! Second stock with the same params when the giveplayerid will accept the repair!

There will be two CMD's also! I can script this but i wont be able to test it as my compiler isnt working properly!

Hope i helped a bit!

Regards
Ballu Miaa
Reply
#3

Thanks for suggestion, but still, anyone?
Reply
#4

u want to make it so that engineer must wait 2 minutes before refixing a car ?

if so:

new WaitVeriable[MAX_PLAYERS];

before you send a message or repair put the following:

if(WaitVeriable[playerid] - gettime() >=120) return SendClientMessage(playerid,color,"ERROR");

and after you repeared and sending it put:
WaitVeriable[playerid] = gettime();

sry but iam not online with my computer so i cant write you the full code
Reply
#5

no, i mean is if mechanic fix the car, it would take 2 minutes.
then inside the timer called "VehicleRepair" i will get this

"Mechanic Engineer %s has successfully fix %s's vehicle engine" <<<< i don't know how to do this
and also the mechanic will get $5,000 from the owner of vehicle engine
Reply
#6

Use this
pawn Код:
TogglePlayerControllable(playerid, 1);
SetTimerEx("mechunfreeze", "i", playerid);
//...
pawn Код:
public mechunfreeze(playerid)
{
    TogglePlayerControllable(playerid, 0);
}
I hope you get a help from this
Reply
#7

*/ remove pls, i hate my phone -,-/*
Reply
#8

ok
after your sends put:
SetTimerEx("FixCar",120*1000,"ii",playerid,fixid);


END of script:
stock FixCar(playerid,fixid)
{
//playerid = engineer
//fixid = fix player which the engineer fixes
return 1;
}
Reply
#9

pawn Код:
CMD:repair(playerid, params[])
{
    new string[120], id;
    if(pInfo[playerid][JobMember] == 2 || pInfo[playerid][JobLeader] == 2)
    {
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /repair [playerid]");
        if(IsPlayerInAnyVehicle(playerid)) {
            if(GetPlayerMoney(id) < 5000) return SendClientMessage(id, COLOR_GREY, "You do not have enough money to pay the mechanic engineer!");
            format(string, sizeof(string), "Mechanic Engineer %s is fixng %s's vehicle engine...", GetName(playerid), GetName(id));
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string, sizeof(string), "Mechanic Engineer %s will gonna fix your vehicle engine...", GetName(playerid));
            SendClientMessage(id, COLOR_YELLOW, string);
            format(string, sizeof(string), "You fixing %s's vehicle engine", GetName(id));
            SendClientMessage(playerid, COLOR_YELLOW, string);
            new vehID = GetPlayerVehicleID(id);
            TogglePlayerControllable(playerid, false);
            TogglePlayerControllable(id, false);
            SetTimerEx("RepairCar", 60000 * 2, false, "iii", playerid, id, vehID);
        } else {
            SendClientMessage(playerid, COLOR_GREY, "  You are not Mechanic Engineer!  ");
        }
    }
    return 1;
}
forward RepairCar(playerid, giveplayerid, vehicleid);
public RepairCar(playerid, giveplayerid, vehicleid)
{
           SetVehicleHealth(vehicleid, 1000);
            RepairVehicle(vehicleid);
            format(string, sizeof(string), "Mechanic Engineer %s has sucessfully fix %s's vehicle engine", GetName(playerid), GetName(giveplayerid));
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string, sizeof(string), "Mechanic Engineer %s has fix your vehicle engine, you will pay 5,000$", GetName(playerid));
            SendClientMessage(id, COLOR_YELLOW, string);
            format(string, sizeof(string), "You sucessfully fix %s's vehicle engine, he/she pays you 5,000$", GetName(giveplayerid));
            SendClientMessage(playerid, COLOR_YELLOW, string);
            GivePlayerMoney(playerid, 5000);
            GivePlayerMoney(giveplayerid, -5000);
            TogglePlayerControllable(playerid, true);
            TogglePlayerControllable(giveplayerid, true);
}
Now, both players will be frozen for two minutes, till the mechanic will finish the repair. Only after those two minutes, the vehicle will be repaired and the mechanic will get the money.

This is what you needed ?
Reply
#10

Quote:
Originally Posted by antonio112
Посмотреть сообщение
pawn Код:
CMD:repair(playerid, params[])
{
    new string[120], id;
    if(pInfo[playerid][JobMember] == 2 || pInfo[playerid][JobLeader] == 2)
    {
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /repair [playerid]");
        if(IsPlayerInAnyVehicle(playerid)) {
            if(GetPlayerMoney(id) < 5000) return SendClientMessage(id, COLOR_GREY, "You do not have enough money to pay the mechanic engineer!");
            format(string, sizeof(string), "Mechanic Engineer %s is fixng %s's vehicle engine...", GetName(playerid), GetName(id));
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string, sizeof(string), "Mechanic Engineer %s will gonna fix your vehicle engine...", GetName(playerid));
            SendClientMessage(id, COLOR_YELLOW, string);
            format(string, sizeof(string), "You fixing %s's vehicle engine", GetName(id));
            SendClientMessage(playerid, COLOR_YELLOW, string);
            new vehID = GetPlayerVehicleID(id);
            TogglePlayerControllable(playerid, false);
            TogglePlayerControllable(id, false);
            SetTimerEx("RepairCar", 60000 * 2, false, "iii", playerid, id, vehID);
        } else {
            SendClientMessage(playerid, COLOR_GREY, "  You are not Mechanic Engineer!  ");
        }
    }
    return 1;
}
forward RepairCar(playerid, giveplayerid, vehicleid);
public RepairCar(playerid, giveplayerid, vehicleid)
{
           SetVehicleHealth(vehicleid, 1000);
            RepairVehicle(vehicleid);
            format(string, sizeof(string), "Mechanic Engineer %s has sucessfully fix %s's vehicle engine", GetName(playerid), GetName(giveplayerid));
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string, sizeof(string), "Mechanic Engineer %s has fix your vehicle engine, you will pay 5,000$", GetName(playerid));
            SendClientMessage(id, COLOR_YELLOW, string);
            format(string, sizeof(string), "You sucessfully fix %s's vehicle engine, he/she pays you 5,000$", GetName(giveplayerid));
            SendClientMessage(playerid, COLOR_YELLOW, string);
            GivePlayerMoney(playerid, 5000);
            GivePlayerMoney(giveplayerid, -5000);
            TogglePlayerControllable(playerid, true);
            TogglePlayerControllable(giveplayerid, true);
}
Now, both players will be frozen for two minutes, till the mechanic will finish the repair. Only after those two minutes, the vehicle will be repaired and the mechanic will get the money.

This is what you needed ?
Yes thats what i need thanks, now gonna test it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)