Am I doing this right?
#1

So yeah I made a repair command and just want to know if im doing it right (works fine ingame) and how can i add a Timer so you only can do the command evey 1min or so


Код:
CMD:repair(playerid, params[])
{
	if(playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "/repair to repair your vehicle!");
	else if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
	else if(!IsPlayerInRangeOfPoint(playerid, 7.0, 1564.8927, -1612.5355, 13.2718)) return SendClientMessage(playerid, 0xFF0000FF, "Your not at the repair point");
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
    return 1;
}
Reply
#2

pawn Код:
new RepairSpam[MAX_PLAYERS];
pawn Код:
CMD:repair(playerid, params[])
{
        if(RepairSpam[playerid] == 1) return SendClientMessage(playerid,0xFFFFFFFF,"Please wait efore using this    command again");
    if(playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "/repair to repair your vehicle!");
    else if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
    else if(!IsPlayerInRangeOfPoint(playerid, 7.0, 1564.8927, -1612.5355, 13.2718)) return SendClientMessage(playerid, 0xFF0000FF, "Your not at the repair point");
    RepairVehicle(GetPlayerVehicleID(playerid));
    RepairSpam[playerid] = 1;
    SetTimerEx("Repair",60000,0,"d",playerid);
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
    return 1;
}
pawn Код:
forward Repair(playerid);
public Repair(playerid)
{
  RepairSpam[playerid] = 0;
}
Reply
#3

add a variable :
pawn Код:
//global
new RepairTime[MAX_PLAYERS];

CMD:repair(playerid, params[])
{
    //if(playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "/repair to repair your vehicle!");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
    else if(!IsPlayerInRangeOfPoint(playerid, 7.0, 1564.8927, -1612.5355, 13.2718)) return SendClientMessage(playerid, 0xFF0000FF, "Your not at the repair point");
        else if(RepairTime[playerid] != 0) return SendClientMessage(playerid, 0xFF0000FF, "You need to wait 1 minute before use repair again");
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
    RepairTime[playerid] = 1;
    SetTimerEx("RepairCD",1000*60,0,"i",playerid);
    return 1;
}
forward RepairCD(playerid);
public RepairCD(playerid)
{
RepairTime[playerid] = 0;
return 1;
}

public OnPlayerConnect(playerid)
{
RepairTime[playerid] = 0;
}
public OnPlayerDisconnect(playerid)
{
RepairTime[playerid] = 0;
}
Reply
#4

pawn Код:
SetTimerEx("VehicleTime", 60000, false, "i", playerid);
Create the timer.

[pawn]
forward VehicleTime(playerid);
public VehicleTime(playerid)
{
SomeFunc[playerid] = false;
return 1;
}

Reset the function.

pawn Код:
// Under command
SomeFunc[playerid] = true;
Create a global variable named "SomeFunc[MAX_PLAYERS];"
Reply
#5

This only 'works fine ingame' if you're ID 0. The first statement will always come true for any other player, rendering the command totally useless.
Reply
#6

Thanks guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)