Editing: Fishing System-Problem
#1

Alright, well the filterscript works, again i'm just editing it so I do not have to go to a certain place to fish instead just fish on a boat. However, when I take the filterscript off my .cfg my /commands for gamemode works perfect, but when I put it on, something is interfering, here is the code for what I have edited, if any suggestions on why its stopping me from using my commands i'd appreciate it.

pawn Код:
#include <a_samp>
#include <string>
#include <core>

//--------|| Here you can easy change prices ||-------||
#define BaitPrice 15
#define FishingToolPrice 150

//--------|| dcmd by DracoBlue ||---------------------||
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
//--------|| Colors ||--------------------------------||
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x9EC73DAA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xDABB3EAA
#define COLOR_YELLOW2 0xF5DEB3AA
#define COLOR_GREENYELLOW 0xADFF2FFF
#define COLOR_PURPLE 0xB370FCFF
#define COLOR_WHITE 0xFFFFFFAA
//----------------------------------------------------||

new Fishes[MAX_PLAYERS];
new AlreadyFished[MAX_PLAYERS];
new FishingTool[MAX_PLAYERS];
new Worms[MAX_PLAYERS];
new FishWeight[MAX_PLAYERS];
new IsFishing[MAX_PLAYERS];
new fishing;

forward IsAtFishPlace(playerid);
forward FishTime(playerid);
forward SendRPMessage(playerid, Float:radius, color, string[]);
forward StopFish(playerid);

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Fishing System by BumbiS* started");
    print("--------------------------------------\n");
    /////////////////////////////////////////////////
    fishing = AddStaticPickup(1239, 23, 153.9523,-1946.2955,5.1874);
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    Worms[playerid] = 0; FishingTool[playerid] = 0; AlreadyFished[playerid] = 0;
    Fishes[playerid] = 0; FishWeight[playerid] = 0; IsFishing[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    Worms[playerid] = 0; FishingTool[playerid] = 0; AlreadyFished[playerid] = 0;
    Fishes[playerid] = 0; FishWeight[playerid] = 0; IsFishing[playerid] = 0;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    Worms[playerid] = 0; FishWeight[playerid] = 0;
    Fishes[playerid] = 0; FishingTool[playerid] = 0;
    return 1;
}
//-----------DCMD Commands--------------------||
dcmd_buytools(playerid, params[])
{
    #pragma unused params
    if(IsPlayerInRangeOfPoint(playerid, 2.5,153.9523,-1946.2955,5.1874))
    {
        new string[128];
        format(string,128,"FishingTools     $%d\nWorms      $%d per one",FishingToolPrice,BaitPrice);
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Fishing tools", string,"Purchase","Exit");
        return 1;
    }
    return 1;
}
dcmd_inventory(playerid, params[])
{
    #pragma unused params
    new string[128];
    new string2[128];
    new string3[128];
    SendClientMessage(playerid, COLOR_GREEN, "____|| Your inventory ||___");
    if(FishingTool[playerid]==1)
    {
        format(string,sizeof(string)," -  Fishing Tool");
        SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    if(Worms[playerid]>0)
    {
        format(string2,sizeof(string2)," -  %d Worms", Worms[playerid]);
        SendClientMessage(playerid, COLOR_YELLOW, string2);
    }
    if(Fishes[playerid]>0)
    {
        format(string3,sizeof(string3)," -  %d fishes", Fishes[playerid]);
        SendClientMessage(playerid, COLOR_YELLOW, string3);
    }
    SendClientMessage(playerid, COLOR_GREEN, "___________________________");
    return 1;
}
dcmd_fishhelp(playerid,params[])
{
    #pragma unused params
    SendClientMessage(playerid,COLOR_GREEN,"________|| Fishing Help ||___________");
    SendClientMessage(playerid,COLOR_WHITE,"/fish");
    SendClientMessage(playerid,COLOR_WHITE,"/releaseallfishes");
    SendClientMessage(playerid,COLOR_WHITE,"/sellfishes");
    SendClientMessage(playerid,COLOR_GREEN,"_____________________________________");
    return 1;
}
dcmd_releaseallfishes(playerid,params[])
{
    #pragma unused params
    if(Fishes[playerid] > 0 )
    {
        SendClientMessage(playerid, COLOR_YELLOW2, "You released all fishes back in sea.");
        Fishes[playerid] = 0;
        FishWeight[playerid] = 0;
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You already don't have fishes or you are not at fishing place(Big Wheel)");
        return 1;
    }
}

dcmd_fish(playerid,params[])
{
    #pragma unused params
    new string[128];
    new name[MAX_PLAYER_NAME];

         if(IsPlayerInAnyVehicle(playerid))
            {
                if(AlreadyFished[playerid] == 0 && IsFishing[playerid] == 0)
                {
                    if(Fishes[playerid] >= 15)
                    {
                        SendClientMessage(playerid,COLOR_RED,"You have enough fishes and you are tiered of fishing.");
                        SendClientMessage(playerid,COLOR_RED,"You can sell your fishes at Los Santos docks (/sellfish @ CheckPoint)");
                        AlreadyFished[playerid] = 1;
                        SetPlayerCheckpoint(playerid, 2766.6602,-2575.1614,3.0000,3.0);
                        SetTimerEx("StopFish", 1000*60*10, 0, "i",playerid);
                    }
                    else
                    {
                        new random2 = randomEx(4000,14000);
                        IsFishing[playerid] = 1;
                        SetTimerEx("FishTime", random2, 0, "i",playerid);
                        GetPlayerName(playerid,name,sizeof(name));
                        format(string,sizeof(string),"%s is fishing.",name);
                        SendRPMessage(playerid, 20.0, COLOR_PURPLE, string);
                        GameTextForPlayer(playerid, "~w~Fishing...",random2,3);
                        TogglePlayerControllable(playerid, false);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "You need to wait some time to fish again.");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not at fishing place(Big Whell or on water)");
                return 1;
            }

}
dcmd_sellfish(playerid,params[])
{
    #pragma unused params
    if(Fishes[playerid] >= 1)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0,2766.6602,-2575.1614,3.0000))
        {
            new string[128];
            Fishes[playerid] = 0;
            format(string,sizeof(string),"You sold all your fishes for $%d.", FishWeight[playerid]);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            GivePlayerMoney(playerid, FishWeight[playerid]);
            FishWeight[playerid] = 0;
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You need to be at Los Santos docks.");
            SetPlayerCheckpoint(playerid, 2766.6602,-2575.1614,3.0000,3.0);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You dont have any fishes that you can sell.");
        return 1;
    }
    return 1;
}
           
//--------------------------------------------||
public OnPlayerCommandText(playerid, cmdtext[])
{
   
    dcmd(inventory,9,cmdtext);
    dcmd(fishhelp,8,cmdtext);
    dcmd(releaseallfishes,16,cmdtext);
    dcmd(fish,4,cmdtext);
    dcmd(sellfish,8,cmdtext);
    return 0;
}
public OnPlayerEnterCheckpoint(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 3.0,2766.6602,-2575.1614,3.0000))
    {
        if(Fishes[playerid] >= 1)
        {
            new string[128];
            Fishes[playerid] = 0;
            format(string,sizeof(string),"You sold all your fishes for $%d.", FishWeight[playerid]);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            GivePlayerMoney(playerid, FishWeight[playerid]);
            FishWeight[playerid] = 0;
            DisablePlayerCheckpoint(playerid);
            return 1;
        }
    }
    return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == fishing)
    {
        GameTextForPlayer(playerid, "~w~You can buy here~n~some fishing tools~n~type ~r~/buytools ~w~to buy some", 3500, 3);
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(listitem == 0)
        {
            if(GetPlayerMoney(playerid) >= FishingToolPrice)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Successfully purchased Fishing tool! You can now use /fish");
                SendClientMessage(playerid, COLOR_YELLOW, ", but you also need some baits");
                FishingTool[playerid] = 1;
                GivePlayerMoney(playerid, -FishingToolPrice);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You don't have enough money");
            }
        }
        if(listitem == 1)
        {
            new string[128];
            format(string,sizeof(string),"Enter below how much baits do you want.\n$%d per one",BaitPrice);
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Baits",string,"Purchase","Exit");
        }
    }
    if(dialogid == 2 && response)
    {
    new price = BaitPrice;
        new string[128];
        new baits = strval(inputtext);
        if(baits > 0)
        {
            new price1 = price*baits;
            if(GetPlayerMoney(playerid) >= price1)
            {
                GivePlayerMoney(playerid, -price1);
                format(string,sizeof(string),"You just purchased %d worms for $%d", baits, price1);
                SendClientMessage(playerid, COLOR_GREEN, string);
                Worms[playerid] += baits;
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You don't have that much money.");
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You can't buy baits less than 0");
        }
    }
    return 1;
}

public FishTime(playerid)
{
    new string[128];
    if(IsPlayerConnected(playerid))
    {
        new rand = randomEx(1,11);
        new weight = randomEx(50,180);
        new money = randomEx(20, 80);
        if(rand == 1)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out some trash and throwed it back in sea");
            Worms[playerid] -= 1;
            IsFishing[playerid] = 0;
            TogglePlayerControllable(playerid,true);
            return 1;
        }
        else if(rand == 2)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out tuna!");
            Fishes[playerid] += 1;
            Worms[playerid] -= 1;
            IsFishing[playerid] = 0;
            FishWeight[playerid] += weight;
            TogglePlayerControllable(playerid,true);
            return 1;
        }
        else if(rand == 3)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Swordfish!");
            Fishes[playerid] += 1;
            IsFishing[playerid] = 0;
            Worms[playerid] -= 1;
            FishWeight[playerid] += weight;
            TogglePlayerControllable(playerid,true);
            return 1;
        }
        else if(rand == 4)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Blue Marlin!");
            Fishes[playerid] += 1;
            Worms[playerid] -= 1;
            IsFishing[playerid] = 0;
            FishWeight[playerid] += weight;
            TogglePlayerControllable(playerid,true);
            return 1;
        }
        else if(rand == 5)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Shark!");
            Fishes[playerid] += 1;
            Worms[playerid] -= 1;
            IsFishing[playerid] = 0;
            FishWeight[playerid] += weight;
            TogglePlayerControllable(playerid,true);
            return 1;
        }
        else if(rand == 6)
        {
            format(string,sizeof(string),"You just fished out Wallet and in there was $%d!", money);
            SendClientMessage(playerid,COLOR_GREENYELLOW,string);
            GivePlayerMoney(playerid, money);
            Worms[playerid] -= 1;
            TogglePlayerControllable(playerid,true);
            IsFishing[playerid] = 0;
            return 1;
        }
        else if(rand == 7)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Eel!");
            Fishes[playerid] += 1;
            TogglePlayerControllable(playerid,true);
            Worms[playerid] -= 1;
            IsFishing[playerid] = 0;
            FishWeight[playerid] += weight;
            return 1;
        }
        else if(rand == 8)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Sea Bass!");
            Fishes[playerid] += 1;
            Worms[playerid] -= 1;
            TogglePlayerControllable(playerid,true);
            IsFishing[playerid] = 0;
            FishWeight[playerid] += weight;
            return 1;
        }
        else if(rand == 9)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Sail Fish!");
            Fishes[playerid] += 1;
            TogglePlayerControllable(playerid,true);
            Worms[playerid] -= 1;
            IsFishing[playerid] = 0;
            FishWeight[playerid] += weight;
            return 1;
        }
        else if(rand == 10)
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You didnt catch anything.");
            Worms[playerid] -= 1;
            TogglePlayerControllable(playerid,true);
            IsFishing[playerid] = 0;
            return 1;
        }
        else
        {
            SendClientMessage(playerid,COLOR_GREENYELLOW,"You didnt catch anything, but you your worm remained");
            IsFishing[playerid] = 0;
            TogglePlayerControllable(playerid,true);
            return 1;
        }
    }
    return 0;
}

//-----------|| Function By BumbiS* ||--------------||
public SendRPMessage(playerid, Float:radius, color, string[])
{
    if(IsPlayerConnected(playerid))
    {
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(playerid,x,y,z);
            if(IsPlayerInRangeOfPoint(i, radius, x,y,z))
            {
                SendClientMessage(i,color,string);
                return 1;
            }
        }
    }
    return 0;
}
//--------------------------------------------------||

//-----------|| By ****** ||---------------||
stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
//----------|| Unknown creater of this, but thanks ||--||
stock IsPlayerInWater(playerid)
{
    new Float:x,Float:y,Float:pz;
    GetPlayerPos(playerid,x,y,pz);
    if (
    (IsPlayerInArea(playerid, 2032.1371, 1841.2656, 1703.1653, 1467.1099) && pz <= 9.0484) //lv piratenschiff
    || (IsPlayerInArea(playerid, 2109.0725, 2065.8232, 1962.5355, 10.8547) && pz <= 10.0792) //lv visage
    || (IsPlayerInArea(playerid, -492.5810, -1424.7122, 2836.8284, 2001.8235) && pz <= 41.06) //lv staucamm
    || (IsPlayerInArea(playerid, -2675.1492, -2762.1792, -413.3973, -514.3894) && pz <= 4.24) //sf sьdwesten kleiner teich
    || (IsPlayerInArea(playerid, -453.9256, -825.7167, -1869.9600, -2072.8215) && pz <= 5.72) //sf gammel teich
    || (IsPlayerInArea(playerid, 1281.0251, 1202.2368, -2346.7451, -2414.4492) && pz <= 9.3145) //ls neben dem airport
    || (IsPlayerInArea(playerid, 2012.6154, 1928.9028, -1178.6207, -1221.4043) && pz <= 18.45) //ls mitte teich
    || (IsPlayerInArea(playerid, 2326.4858, 2295.7471, -1400.2797, -1431.1266) && pz <= 22.615) //ls weiter sьdцstlich
    || (IsPlayerInArea(playerid, 2550.0454, 2513.7588, 1583.3751, 1553.0753) && pz <= 9.4171) //lv pool цstlich
    || (IsPlayerInArea(playerid, 1102.3634, 1087.3705, -663.1653, -682.5446) && pz <= 112.45) //ls pool nordwestlich
    || (IsPlayerInArea(playerid, 1287.7906, 1270.4369, -801.3882, -810.0527) && pz <= 87.123) //pool bei maddog's haus oben
    || (pz < 1.5)
    )
    {
        return 1;
    }
    return 0;
}
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;
return 0;
}
//----------------------------------------------------||
public StopFish(playerid)
{
    AlreadyFished[playerid] = 0;
    SendClientMessage(playerid, COLOR_GREEN, "Hey, you can fish now!");
    return 1;
}


forward IsPlayerOnAnyBoat(playerid);
public IsPlayerOnAnyBoat(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new FXF_vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(FXF_vehicle == 430 || FXF_vehicle == 446 || FXF_vehicle == 452 || FXF_vehicle == 453 || FXF_vehicle == 454 || FXF_vehicle == 472 || FXF_vehicle == 473 || FXF_vehicle == 484 || FXF_vehicle == 493 || FXF_vehicle == 595)
        {
            if(IsPlayerConnected(playerid))
            {
                if(IsPlayerInWater(playerid))
                {
                }
            }
        }
    }
    return 1;
}
Reply
#2

You use dcmd in your GameMode?
Reply
#3

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
You use dcmd in your GameMode?
Yes.
Reply
#4

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
You use dcmd in your GameMode?
Should I use something different? Another filterscript I used has DCMD also.. and it works fine.
Reply
#5

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
You use dcmd in your GameMode?
Quote:
Originally Posted by David5290
Посмотреть сообщение
Should I use something different? Another filterscript I used has DCMD also.. and it works fine.
That can't be the cause, dcmd is a macro defined with the #define instruction, so when it gets compiled all the places it finds 'dcmd' are replaced with the things writtend after the #define dcmd in the *.amx file.
Reply
#6

Can the code just be interfering with the gamemode? Should I add the code from the filterscript to the gamemode?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)