SA-MP Forums Archive
little problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: little problem (/showthread.php?tid=213024)



little problem - bartje01 - 18.01.2011

He guys, I have a script that only works for ID 0 and when ID 0 dives into a checkpoint other people will get a fish added too.

How to fix this?

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{

    if(fishprogress[playerid] == 1)
        {

        SendClientMessage(playerid,COLOR_DARKORANGE,"**Reeling in Fishes**");
        SetTimer("fishtimer",5000,false);
        fishes[playerid] += 1;
        TogglePlayerControllable(playerid,0);
        SetPlayerCheckpoint(playerid,3215.4434,-1035.6681,0.7980,4.0);
        fishprogress[playerid] = 2;
        }
        else
        if(fishprogress[playerid] == 2)
        {
        SendClientMessage(playerid,COLOR_DARKORANGE,"**Reeling in Fishes**");
        SetTimer("fishtimer",5000,false);
        fishes[playerid] += 1;
        TogglePlayerControllable(playerid,0);
        SetPlayerCheckpoint(playerid,3019.4819,-1259.1970,0.8884,4.0);
        fishprogress[playerid] = 3;
        }
        else
        if(fishprogress[playerid] == 3)
        {
        SendClientMessage(playerid,COLOR_DARKORANGE,"**Reeling in Fishes**");
        SetTimer("fishtimer",5000,false);
        fishes[playerid] += 1;
        TogglePlayerControllable(playerid,0);
        SetPlayerCheckpoint(playerid,3115.2380,-511.2403,0.9685,4.0);
        fishprogress[playerid] = 4;
        }
        else
        if(fishprogress[playerid] == 4)
        {
        SendClientMessage(playerid,COLOR_DARKORANGE,"**Reeling in Fishes**");
        SetTimer("fishtimer",5000,false);
        fishes[playerid] += 1;
        TogglePlayerControllable(playerid,0);
        SetPlayerCheckpoint(playerid,2979.5803,-8.0016,1.4147,4.0);
        fishprogress[playerid] = 5;
        }
        else
        if(fishprogress[playerid] == 5)
        {
        SendClientMessage(playerid,COLOR_DARKORANGE,"**Reeling in Fishes**");
        SetTimer("fishtimer",5000,false);
        fishes[playerid] += 1;
        TogglePlayerControllable(playerid,0);
        SetPlayerCheckpoint(playerid,2488.8032,472.4902,0.8335,4.0);
        fishprogress[playerid] = 6;
        }
        else
        if(fishprogress[playerid] == 6)
        {
        SendClientMessage(playerid,COLOR_DARKORANGE,"**Reeling in Fishes**");
        SetTimer("fishtimer",5000,false);
        fishes[playerid] += 1;
        TogglePlayerControllable(playerid,0);
        SetPlayerCheckpoint(playerid,2358.1958,518.7128,-0.3048,4.0);
        fishprogress[playerid] = 7;
        }
        else
        if(fishprogress[playerid] == 7)
        {
        SendClientMessage(playerid,COLOR_DARKORANGE,"Taking your fishes out of the boat");
        SetTimer("fishtimer",15000,false);
        fishes[playerid] += 1;
        TogglePlayerControllable(playerid,0);
        DisablePlayerCheckpoint(playerid);
        fishprogress[playerid] = 8;

        }

    return 1;
}
my command:
pawn Код:
COMMAND:fish(playerid,params[])
{
if(!IsPlayerInRangeOfPoint(playerid, 7.0, 2941.1365,-2051.7290,3.5480)) return SendClientMessage(playerid,COLOR_DARKORANGE,"You're not at the fishing place");
if(fishprogress[playerid] > 0) return SendClientMessage(playerid,COLOR_DARKORANGE,"You're already doing this job!");
else
fishprogress[playerid] = 1;
SendClientMessage(playerid,COLOR_DARKORANGE,"You've started your fishing job. Take a boat and go to the checkpoints!");
SetPlayerCheckpoint(playerid,3019.4819,-1259.1970,0.8884,4.0);
return 1;
}
Please help


Re: little problem - Lorenc_ - 18.01.2011

in the callback public OnPlayerEnterCheckpoint(playerid) you have to add something like

if(CHECKPOINT == FISHCP) // checks if the players in the cp

Or something like that


Re: little problem - bartje01 - 18.01.2011

SO I have to use a checkpoint streamer?...
I don't think so.
I've done this before.


Re: little problem - bartje01 - 18.01.2011

Sorry for the freaking to fast bump. But I really need to know this before I can go on.


Re: little problem - JaTochNietDan - 18.01.2011

Can you show us the public fishtimer function?


Re: little problem - bartje01 - 18.01.2011

I'll send you guys the script.
It's small :P

http://pastebin.com/r3KXxmWc


Re: little problem - JaTochNietDan - 18.01.2011

Well there's your problem, that function loops through everyone in the server and runs the code on them.

You need to make a function for a single person.


Re: little problem - jamesbond007 - 18.01.2011

Use

SetTimerEx


Re: little problem - JaTochNietDan - 18.01.2011

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
Use

SetTimerEx
Well yes, but he'll also have to edit the function, as it currently loops through all players. Merely changing to SetTimerEx won't fix the issue.


Re: little problem - bartje01 - 18.01.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Well yes, but he'll also have to edit the function, as it currently loops through all players. Merely changing to SetTimerEx won't fix the issue.
Then you can fix it, right?
Btw. how can the timer be wrong with this issue?
The fishes are given when he dives into a checkpoint. not at the timer.