Repair Command Problem
#1

See i got an problem with the repair command .

I am trying to make that the vehicle get's repaired after 15 secs , but it wont work . Give a look at this :

pawn Код:
COMMAND:repair(playerid, params[])
{
    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/repair", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Check if the player's admin-level is at least 1
        if (APlayerData[playerid][PlayerLevel] >= 1)
        {
            // Check if the player is inside a vehicle
            if(!IsPlayerInAnyVehicle(playerid))
                return SendClientMessage(playerid, 0xFF0000FF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
            // Fully repair the vehicle (damage value and bodywork)
            SetTimer("Repair_CMD", 15000, false);
            SendClientMessage(playerid, 0xFF9900AA, "Assistance called . Your vehicle will be repaired in 15 minutes");
//          RepairVehicle(GetPlayerVehicleID(playerid));
            // Send the player a message to inform him that his vehicle has been repaired
//          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
        }
        else
            return 0;
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
And the forwarded timer is here :

pawn Код:
public Repair_CMD()
{
          new playerid, vehicleid = GetPlayerVehicleID(playerid);
          SetVehicleHealth(vehicleid, 1000.0);
          // Send the player a message to inform him that his vehicle has been repaired
          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
          return 1;
}
It is already forwarded at top of script :

pawn Код:
forward Repair_CMD();
idk what's wrong with it . The message "Assistance called etc" appears but the repair wont happen . Any suggestion ?
Reply
#2

Use RepairVehicle function. It repairs the visual damage (bumps, dents, scratches, wheels and the actual health) of a vehicle.
Reply
#3

Try this

pawn Код:
COMMAND:repair(playerid, params[])
{
    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/repair", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Check if the player's admin-level is at least 1
        if (APlayerData[playerid][PlayerLevel] >= 1)
        {
            // Check if the player is inside a vehicle
            if(!IsPlayerInAnyVehicle(playerid))
                return SendClientMessage(playerid, 0xFF0000FF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
            // Fully repair the vehicle (damage value and bodywork)
            SetTimer("Repair_CMD", 15000, true);
            SendClientMessage(playerid, 0xFF9900AA, "Assistance called . Your vehicle will be repaired in 15 minutes");
//          RepairVehicle(GetPlayerVehicleID(playerid));
            // Send the player a message to inform him that his vehicle has been repaired
//          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
        }
        else
            return 0;
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
And on the callback
pawn Код:
public Repair_CMD()
{
          RepairVehicle(GetPlayerVehicleID(playerid));
          // Send the player a message to inform him that his vehicle has been repaired
          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
          return 1;
}
Reply
#4

In The Repair_CMD Callback you made, Replace SetVehicleHealth with this code:

pawn Код:
RepairVehicle(GetPlayerVehicleID(playerid));
And it will work.
Reply
#5

Why are you repating the SetTimer every 15 minutes ?
Use this command:
pawn Код:
COMMAND:repair(playerid, params[])
{
    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/repair", params);

    // Check if the player has logged in
    if (!APlayerData[playerid][LoggedIn])
        return 0;
    // Check if the player's admin-level is at least 1
    if(APlayerData[playerid][PlayerLevel] < 1)
        return 0;
    // Check if the player is inside a vehicle
    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid, 0xFF0000FF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
    // Fully repair the vehicle (damage value and bodywork)
    SetTimer("Repair_CMD", 15000, false);
    SendClientMessage(playerid, 0xFF9900AA, "Assistance called . Your vehicle will be repaired in 15 minutes");
    // RepairVehicle(GetPlayerVehicleID(playerid));
    // Send the player a message to inform him that his vehicle has been repaired
    // SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");

    // Let the server know that this was a valid command
    return 1;
}
Reply
#6

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
In The Repair_CMD Callback you made, Replace SetVehicleHealth with this code:

pawn Код:
RepairVehicle(GetPlayerVehicleID(playerid));
And it will work.
Not working

@Anonymouse It is not working and for all others who gave this idea it is not working as i tested it before .
Reply
#7

Try this:
pawn Код:
COMMAND:repair(playerid, params[])
{
    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/repair", params);

    // Check if the player has logged in
    if (!APlayerData[playerid][LoggedIn]) return 0;
    // Check if the player's admin-level is at least 1
    if(APlayerData[playerid][PlayerLevel] < 1) return 0;
    // Check if the player is inside a vehicle
    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid, 0xFF0000FF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
    // Fully repair the vehicle (damage value and bodywork)
    SetTimerEx("Repair_CMD", 15000, false, "i", playerid);
    SendClientMessage(playerid, 0xFF9900AA, "Assistance called . Your vehicle will be repaired in 15 minutes");
//  RepairVehicle(GetPlayerVehicleID(playerid));
    // Send the player a message to inform him that his vehicle has been repaired
//  SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");

    // Let the server know that this was a valid command
    return 1;
}

public Repair_CMD(playerid)
{
    RepairVehicle(GetPlayerVehicleID(playerid));
    // Send the player a message to inform him that his vehicle has been repaired
    SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
    return 1;
}
EDIT: And change "forward Repair_CMD();" to "forward Repair_CMD(playerid);"
Reply
#8

Still not working

EDIT: These are the new codes :

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

forward Repair_CMD(playerid);

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Test");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/repair", cmdtext, true, 10) == 0)
    {
            if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid, 0xFF0000FF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
            // Fully repair the vehicle (damage value and bodywork)
            SetTimerEx("Repair_CMD", 15000, true, "i", playerid);
            SendClientMessage(playerid, 0xFF9900AA, "Assistance called . Your vehicle will be repaired in 1 minutes");
//          RepairVehicle(GetPlayerVehicleID(playerid));
            // Send the player a message to inform him that his vehicle has been repaired
//          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
            return 1;
    }
    return 0;
}

public Repair_CMD()
{
          new playerid;
          RepairVehicle(GetPlayerVehicleID(playerid));
          // Send the player a message to inform him that his vehicle has been repaired
          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
          return 1;
}
FIXED !
Reply
#9

pawn Код:
public Repair_CMD(playerid)
{
          RepairVehicle(GetPlayerVehicleID(playerid));
          // Send the player a message to inform him that his vehicle has been repaired
          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
          return 1;
}
Also, to make the timer not repeat:

pawn Код:
SetTimerEx("Repair_CMD", 15000, false, "i", playerid);
Reply
#10

1. you should use public Repair_CMD(playerid) and not public Repair_CMD()
2. use SetTimerEx.

Try this
pawn Код:
COMMAND:repair(playerid, params[])
{
    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/repair", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Check if the player's admin-level is at least 1
        if (APlayerData[playerid][PlayerLevel] >= 1 )
        {
            // Check if the player is inside a vehicle
            if(!IsPlayerInAnyVehicle(playerid))
                return SendClientMessage(playerid, 0xFF0000FF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
            // Fully repair the vehicle (damage value and bodywork)
            SetTimerEx("Repair_CMD",15000,0,"d",playerid);
            SendClientMessage(playerid, 0xFF9900AA, "Assistance called . Your vehicle will be repaired in 15 seconds");
            // Send the player a message to inform him that his vehicle has been repaired
//          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
        }
        else
            return 0;
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
pawn Код:
forward Repair_CMD(playerid);
pawn Код:
public Repair_CMD(playerid)
{
          new vehicleid = GetPlayerVehicleID(playerid);
          SetVehicleHealth(vehicleid, 1000.0);
          RepairVehicle(vehicleid);
          // Send the player a message to inform him that his vehicle has been repaired
          SendClientMessage(playerid, 0x00FF00FF, "Your vehicle has been successfully repaired!");
          return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)