SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 22/03/2012, 05:24 AM   #1
Reklez
Gangsta
 
Reklez's Avatar
 
Join Date: Mar 2012
Location: Philippines
Posts: 568
Reputation: 64
Default Adding a 2 minute timer to /repair?

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 Code:
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;
}
__________________

Asking a reputation for Server Advertisement? You kidding me, You are totally n00b!
Reklez is offline   Reply With Quote
Old 22/03/2012, 05:28 AM   #2
Ballu Miaa
High-roller
 
Ballu Miaa's Avatar
 
Join Date: Apr 2010
Location: New Delhi,India
Posts: 1,911
Reputation: 313
Default Re: Adding a 2 minute timer to /repair?

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
__________________


I will take half payment as an advance to script for you.
Click here to request my Scripting Service.

Ballu Miaa is offline   Reply With Quote
Old 22/03/2012, 05:40 AM   #3
Reklez
Gangsta
 
Reklez's Avatar
 
Join Date: Mar 2012
Location: Philippines
Posts: 568
Reputation: 64
Default Re: Adding a 2 minute timer to /repair?

Thanks for suggestion, but still, anyone?
__________________

Asking a reputation for Server Advertisement? You kidding me, You are totally n00b!
Reklez is offline   Reply With Quote
Old 22/03/2012, 06:34 AM   #4
Tigerkiller
Gangsta
 
Tigerkiller's Avatar
 
Join Date: May 2010
Posts: 757
Reputation: 25
Default AW: Adding a 2 minute timer to /repair?

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
Tigerkiller is offline   Reply With Quote
Old 22/03/2012, 06:36 AM   #5
Reklez
Gangsta
 
Reklez's Avatar
 
Join Date: Mar 2012
Location: Philippines
Posts: 568
Reputation: 64
Default Re: Adding a 2 minute timer to /repair?

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
__________________

Asking a reputation for Server Advertisement? You kidding me, You are totally n00b!
Reklez is offline   Reply With Quote
Old 22/03/2012, 06:41 AM   #6
RoleplayEditor
Huge Clucker
 
RoleplayEditor's Avatar
 
Join Date: May 2011
Location: At my server :P
Posts: 224
Reputation: 25
Default Re: Adding a 2 minute timer to /repair?

Use this
pawn Code:
TogglePlayerControllable(playerid, 1);
SetTimerEx("mechunfreeze", "i", playerid);
//...
pawn Code:
public mechunfreeze(playerid)
{
    TogglePlayerControllable(playerid, 0);
}
I hope you get a help from this
__________________
Hey
RoleplayEditor is offline   Reply With Quote
Old 22/03/2012, 06:45 AM   #7
Tigerkiller
Gangsta
 
Tigerkiller's Avatar
 
Join Date: May 2010
Posts: 757
Reputation: 25
Default AW: Adding a 2 minute timer to /repair?

*/ remove pls, i hate my phone -,-/*
Tigerkiller is offline   Reply With Quote
Old 22/03/2012, 06:48 AM   #8
Tigerkiller
Gangsta
 
Tigerkiller's Avatar
 
Join Date: May 2010
Posts: 757
Reputation: 25
Default AW: Adding a 2 minute timer to /repair?

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;
}
Tigerkiller is offline   Reply With Quote
Old 22/03/2012, 06:54 AM   #9
antonio112
High-roller
 
antonio112's Avatar
 
Join Date: Aug 2009
Location: Romania
Posts: 1,013
Reputation: 86
Default Re: Adding a 2 minute timer to /repair?

pawn Code:
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 ?
__________________
antonio112 is offline   Reply With Quote
Old 22/03/2012, 06:57 AM   #10
Reklez
Gangsta
 
Reklez's Avatar
 
Join Date: Mar 2012
Location: Philippines
Posts: 568
Reputation: 64
Default Re: Adding a 2 minute timer to /repair?

Quote:
Originally Posted by antonio112 View Post
pawn Code:
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
__________________

Asking a reputation for Server Advertisement? You kidding me, You are totally n00b!
Reklez is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textdraw minute timer! Admigo Help Archive 8 14/05/2011 08:51 PM
5 minute timer then reset with text? -Rebel Son- Help Archive 0 30/01/2010 03:50 AM
vehicle auto-repair timer wangdata Help Archive 6 28/01/2010 09:54 AM
Help with a timer to use the command per minute. speedruntrainer Help Archive 7 16/09/2009 09:09 PM
Timer updated for a player every minute. SpiderPork Help Archive 16 08/02/2009 09:55 AM


All times are GMT. The time now is 07:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.