Repair in checkpoint with command
#1

Hey, I made a bunch of saved positions for repair points but how can I make a checkpoint like thing that I have to be in it and I type /repair in the car to repair? Thanks (I have all of the coords if you need them)
Reply
#2

CMD:repair(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid, radius, x, y, z)) return SendClientMessage(playerid, -1, "You can't do that here");
rest of command
}

or you can use checkpoints


new repaircheckpoint[playerid] = 0;


SetPlayerCheckPoint(playerid, x, y, z, size);
repaircheckpoint[playerid] = 1;

public OnPlayerEnterCheckpoint
{
if(repaircheckpoint[playerid] = 1)
{
repaircheckpoint[playerid] = 0;
DisablePlayerCheckpoint(playerid);
rest of repair function
}
}
Reply
#3

I have multiple checkpoints however, how could I just work with them?
Reply
#4

*bump*
Reply
#5

If all checkpoints are repair checkpoints you might as well just use IsPlayerInCheckpoint. For some reason that functions always seems to be forgotten. Apparently it's much more fun to copy coordinates.
Reply
#6

You can do so:

pawn Код:
CMD:repair(playerid, params[])
{
    if( IsPlayerInRangeOfPoint(playerid, 3.0, 0.0, 0.0, 0.0) ||
        IsPlayerInRangeOfPoint(playerid, 3.0, 0.0, 0.0, 0.0) ||
        IsPlayerInRangeOfPoint(playerid, 3.0, 0.0, 0.0, 0.0) ||
        IsPlayerInRangeOfPoint(playerid, 3.0, 0.0, 0.0, 0.0) ||
        IsPlayerInRangeOfPoint(playerid, 3.0, 0.0, 0.0, 0.0
        /* continue the pattern to add more */)){
        // rest..
    }
    return return SendClientMessage(playerid, -1, "You can't do that here");
}
or so

pawn Код:
stock PlayerIsAnAnyRepairPoint(playerid, Float:range=3.0)
{
    if(!IsPlayerConnected(playerid))
        return -1;

    static Float:RepairPoints[][3] = {
        {0.0, 0.0, 0.0},
        {0.0, 0.0, 0.0},
        {0.0, 0.0, 0.0},
        {0.0, 0.0, 0.0},
        {0.0, 0.0, 0.0},
        {0.0, 0.0, 0.0},
        {0.0, 0.0, 0.0},
        {0.0, 0.0, 0.0}
        // continue the pattern to add more
    };
    for(new i; i < sizeof(RepairPoints); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, range, RepairPoints[i][0], RepairPoints[i][1], RepairPoints[i][2])
        {
            return i;
        }
    }
    return -1;
}

CMD:repair(playerid, params[])
{
    new
        id = PlayerIsAnAnyRepairPoint(playerid);

    if(id == -1)
        return return SendClientMessage(playerid, -1, "You can't do that here");

    // rest..
}
Of course, there are many ways you can find more.
Reply
#7

Thanks. That was all I needed
Reply
#8

C:\SA-MP Servers\SA-MP Server (Mine)\gamemodes\roleplay.pwn(92) : error 001: expected token: ")", but found "{"
C:\SA-MP Servers\SA-MP Server (Mine)\gamemodes\roleplay.pwn(495) : warning 216: nested comment
C:\SA-MP Servers\SA-MP Server (Mine)\gamemodes\roleplay.pwn(602) : error 029: invalid expression, assumed zero
C:\SA-MP Servers\SA-MP Server (Mine)\gamemodes\roleplay.pwn(603) : warning 209: function "@_yCrepair" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Never mind :P Help me fix it?
Reply
#9

We need the code to help you, post it first
Reply
#10

CMD:repair(playerid, params[])
{
new id = PlayerIsAnAnyRepairPoint(playerid);
RepairVehicle(GetPlayerVehicleID(playerid));
if(id == -1) return return SendClientMessage(playerid, -1, "You can't do that here");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)