How to make this work
#1

My /fish command works when I'm driving the boat, but how do I make it so it works if you're on the boat but not driving it like in the photo below?



Fish command:

pawn Код:
CMD:fish(playerid, params[])
{
    new string[128], query[500], pname[24];
    GetPlayerName(playerid, pname, 24);
    if(!IsPlayerLoggedIn(playerid))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not logged in.");
        return 1;
    }
    if(!IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754) && !IsPlayerInVehicle(playerid, Reefer))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
        return 1;
    }
    if(PlayerInfo[playerid][pFishPermit] < 1)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have a fishing permit.");
        return 1;
    }
    if(PlayerInfo[playerid][pFishingRod] < 1)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have a fishing rod.");
        return 1;
    }
    if(PlayerInfo[playerid][pBait] < 1)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have any bait.");
        return 1;
    }
    if(PlayerInfo[playerid][pFishes] == 5)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You cannot hold any more fish in your inventory.");
        return 1;
    }
    if(PlayerInfo[playerid][pRodDurab] == 1)
    {
        format(string, sizeof(string), "* %s's rod has worn out and snapped into two pieces.", Name(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        PlayerInfo[playerid][pFishingRod] = 0;
        PlayerInfo[playerid][pRodDurab] = 0;
        format(query, sizeof(query), "UPDATE playerdata SET FishingRod=%d, RodDurab=%d WHERE Username='%s'",
        PlayerInfo[playerid][pFishingRod],
        PlayerInfo[playerid][pRodDurab],
        pname);
        mysql_query(query);
        return 1;
    }
    TogglePlayerControllable(playerid, 0);
    PlayerInfo[playerid][pRodDurab] -= 1;
    PlayerInfo[playerid][pBait] -= 1;
    format(query, sizeof(query), "UPDATE playerdata SET RodDurab=%d, Bait=%d WHERE Username='%s'",
    PlayerInfo[playerid][pRodDurab],
    PlayerInfo[playerid][pBait],
    pname);
    mysql_query(query);
    format(string, sizeof(string), "* %s casts their rod out into the sea.", Name(playerid));
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    SetTimerEx("FishingTime", 15000, false, "i", playerid);
    return 1;
}
Reply
#2

replace

Quote:

if(!IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754) && !IsPlayerInVehicle(playerid, Reefer))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
return 1;
}

with


Код:
if(!IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
        return 1;
    }
Reply
#3

I suggest you use GetPlayerSurfingVehicleID. Here

If you edit it right it will let you fish when you are on top of the boat.

If you use what the poster above said, you can only fish from that point and not in any boats...
Reply
#4

I don't understand this surfing thing, but my boat is this:

pawn Код:
Reefer = AddStaticVehicleEx(453, 2106.5476, -96.4246, -0.3409, 123.6812, 1, 1, 1200); // Fishing Reefer (20mins Respawn)
Reply
#5

Quote:
Originally Posted by batonsa
Посмотреть сообщение
I suggest you use GetPlayerSurfingVehicleID. Here

If you edit it right it will let you fish when you are on top of the boat.

If you use what the poster above said, you can only fish from that point and not in any boats...
Are you sure this will work? Because if the vehicle(boat in this case) hasn't got a driver it will return INVALID_VEHICLE_ID
Reply
#6

Yeah that's what I was thinking, I need it so whether there's a driver or no driver people can still /fish on the boat
Reply
#7

Is there any other way? I've seen it done on red county rp.
Reply
#8

Well, its still better than nothing, since this way more than one people can fish from a reefer. You dont need to come off the wheel while you are alone in the boat, do you?
I can't think of anymore functions to do what you want, though.

If you take ls-rp for example then there, aswell, you can /gofishing 2 (meaning from a boat) only if you are the driver.
Reply
#9

Ah, true man, true. Works, +rep.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)