/repair command
#1

how i make player repair car and pay 100$


this is my repair code

Код:
dcmd_repair(playerid, params[])
{
       #pragma unused params 
       RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid,0xFFFF00AA,"Server: Your Vehicle Has Been Repaired!");
       	} else { SendClientMessage(playerid,COLOR_YELLOW,".:: [FUEL]: You must be at a gas station to repair");
    }
    return 1;
}
Reply
#2

pawn Код:
dcmd_repair(playerid, params[])
{
    #pragma unused params
    if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid, COLOR_YELLOW,"You do not have enough money to repair your vehicle!");
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid,0xFFFF00AA,"Server: Your Vehicle Has Been Repaired!");
    GivePlayerMoney(playerid, -100);
    return 1;
}
Unless you provide us with the coords of your gas station, we can't help you with that aspect. Use PlayerIsInRangeOfPoint to check if he's near the coords and continue on with the code. Above simply removed 100 dollars if they have enough cash to repair the vehicle and it repairs it. If not, it sends a client message saying they have not enough money.

"Untested"
Reply
#3

pawn Код:
dcmd_repair(playerid, params[])
{
    #pragma unused params
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_YELLOW,"You must be inside vehicle to use this command!");
    if(IsPlayerInRangeOfPoint(playerid, Put your coords here)) // 'Ok so the player is in range, now what?'
    {
        if(GetPlayerMoney(playerid > 100) // 'Ok so if they have over $100, I will allow them to repair their vehicle'
        {
            RepairVehicle(GetPlayerVehicleID(playerid)); // 'repair'
            SendClientMessage(playerid,0xFFFF00AA,"Server: Your Vehicle Has Been Repaired!"); // ' I will let them know '
        }
        else return SendClientMessage(playerid,-1, "You do not have $100 to repair your vehicle!"); // ' They don't have $100 so I have to tell them they do not have it. '
    }
    return 1;
}
This explains it a bit more.
Reply
#4

For some reasons I would also add check for vehicle...

pawn Код:
dcmd_repair(playerid, params[])
{
    //if(!IsPlayerInRangeOfPoint(playerid,Float:Range,Float:X,Float:Y,Float:Z)) return SendClientMessage(playerid, COLOR_YELLOW,"You must at gas station to use this command!");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_YELLOW,"You must be inside vehicle to use this command!");
    if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid, COLOR_YELLOW,"You do not have enough money to repair your vehicle!");
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid,0xFFFF00AA,"Server: Your Vehicle Has Been Repaired!");
    GivePlayerMoney(playerid, -100);
    return 1;
}
Reply
#5

thanx all but can u add player repair car and player repair again after 1min
Reply
#6

Quote:
Originally Posted by sscarface
Посмотреть сообщение
thanx all but can u add player repair car and player repair again after 1min
We don't understand what you want. Do you want the car to be fixed automatically or do you want the repair to take 1 minute in-game.
Reply
#7

no i want u repair car and after u want again repair so u can repair again after 1 min becasue u can't again again repair early
Reply
#8

pawn Код:
#include <a_samp>

forward RepairTimer(playerid);
new PlayerRepairTimer[MAX_PLAYERS];
new PlayerRepaired[MAX_PLAYERS];

dcmd_repair(playerid, params[])
{
    //if(!IsPlayerInRangeOfPoint(playerid,Float:Range,Float:X,Float:Y,Float:Z)) return SendClientMessage(playerid, COLOR_YELLOW,"You must at gas station to use this command!");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_YELLOW,"You must be inside vehicle to use this command!");
    if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid, COLOR_YELLOW,"You do not have enough money to repair your vehicle!");
    if(PlayerRepaired[playerid]==1) return SendClientMessage(playerid, COLOR_YELLOW,"You have to wait one minute before you can repair your vehicle again!");
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid,0xFFFF00AA,"Server: Your Vehicle Has Been Repaired!");
    GivePlayerMoney(playerid, -100);
   
    PlayerRepairTimer[playerid] = SetTimerEx("RepairTimer",60000,0,"d",playerid);
    PlayerRepaired[playerid]=1;
    return 1;
}

public RepairTimer(playerid)
{
    PlayerRepaired[playerid]=0;
}
-replace your current repair command with this updated one
- add forward RepairTimer(playerid);, new PlayerRepairTimer[MAX_PLAYERS]; and new PlayerRepaired[MAX_PLAYERS]; at the very top of your script (after #includes)
-add public RepairTimer(playerid) at the bottom of your script.
Reply
#9

no work i can repair again n again no timer
Reply
#10

Did you copy the whole command or just
pawn Код:
PlayerRepairTimer[playerid] = SetTimerEx("RepairTimer",60000,0,"d",playerid);
    PlayerRepaired[playerid]=1;
?



I can't spot any errors, so either you added something incorrectly or I'm blind to my own errors (quite possible). It is a simple variable check and timer...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)