SA-MP Forums Archive
Some bugs. - 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)
+--- Thread: Some bugs. (/showthread.php?tid=378119)



Some bugs. - thefatshizms - 16.09.2012

Hello i have a robbery checkpoint and its kinda bug + i dont know how to fix the bugs lol

pawn Код:
public Rob(playerid)
{
    new string[128];
    countn[playerid]--;
    format(string, sizeof(string), "Attempting robbery~n~~b~%i~n~~r~Stay in the checkpoint", countn[playerid]);
    TextDrawSetString(robbery, string);
    TextDrawShowForPlayer(playerid, robbery);
    if(!IsPlayerInDynamicCP(playerid, burgerrob))
    {
        SendClientMessage(playerid, COLOR_RED, "You are supposed to stay in the checkpoint!");
        KillTimer(dstimer[playerid]);
        TextDrawHideForPlayer(playerid, robbery);
    }
    if(countn[playerid]<=0)
    {
        if(IsPlayerInDynamicCP(playerid, burgerrob))
        {
            RobbedR = true;
            SetTimer("RR", 300000, false);
            GivePlayerMoney(playerid, random(50000));
            KillTimer(dstimer[playerid]);
            TextDrawHideForPlayer(playerid, robbery);
        }
    }
    return 1;
}
When your out the checkpoint it just spams you and doesnt stop until ur standing in the checkpoint again
also if say i was in checkpoint and i got 15k every player on the server would get 15 k


Re: Some bugs. - Cypress - 16.09.2012

Where actually do you start the timer and what do you do when player enters a checkpoint he wants to rob?


Re: Some bugs. - thefatshizms - 16.09.2012

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_CROUCH)) {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, 379.0827,-65.4114,1001.5078)) {
            if(RobbedR == false)
            {
                countn[playerid]=12;
                dstimer[playerid]=SetTimerEx("Rob",1000,true,"i",playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "This store has been robbed recently. Please try again");
            }
            return 1;
        }
    }
    return true;
}
thats how you rob it


Re: Some bugs. - Cypress - 16.09.2012

pawn Код:
public Rob(playerid)
{
    if(IsPlayerInDynamicCP(playerid, burgerrob))
    {
        countn[playerid]--;
        new string[128];
        format(string, sizeof(string), "Attempting robbery~n~~b~%i~n~~r~Stay in the checkpoint", countn[playerid]);
        TextDrawSetString(robbery, string);
        TextDrawShowForPlayer(playerid, robbery);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are supposed to stay in the checkpoint!");
        KillTimer(dstimer[playerid]);
        TextDrawHideForPlayer(playerid, robbery);
    }
    if(countn[playerid] <= 0)
    {
        if(IsPlayerInDynamicCP(playerid, burgerrob))
        {
            RobbedR = true;
            SetTimer("RR", 300000, false);
            GivePlayerMoney(playerid, random(50000));
            KillTimer(dstimer[playerid]);
            TextDrawHideForPlayer(playerid, robbery);
        }
    }
    return 1;
}
You can also check if the player was robbing the checkpoint and when he gets out you can stop the robbery like:

pawn Код:
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    if(checkpointid == burgerrob)
    {
       if(countn[playerid] > 0)
       {
          SendClientMessage(playerid, COLOR_RED, "You are supposed to stay in the checkpoint!");
          KillTimer(dstimer[playerid]);
          TextDrawHideForPlayer(playerid, robbery);
          countn[playerid] = 0;
       }
    }
    return 1;
}
If you'll use the one with OnPlayerLeaveDynamicCP then make it like:

pawn Код:
public Rob(playerid)
{
    if(IsPlayerInDynamicCP(playerid, burgerrob))
    {
        countn[playerid]--;
        new string[128];
        format(string, sizeof(string), "Attempting robbery~n~~b~%i~n~~r~Stay in the checkpoint", countn[playerid]);
        TextDrawSetString(robbery, string);
        TextDrawShowForPlayer(playerid, robbery);
    }
    if(countn[playerid] <= 0)
    {
        if(IsPlayerInDynamicCP(playerid, burgerrob))
        {
            RobbedR = true;
            SetTimer("RR", 300000, false);
            GivePlayerMoney(playerid, random(50000));
            KillTimer(dstimer[playerid]);
            TextDrawHideForPlayer(playerid, robbery);
        }
    }
    return 1;
}
I don't know which of the ways will work, just check em out.


Re: Some bugs. - thefatshizms - 16.09.2012

Thanks it now stops spamming me but now whenever i enter the checkpoint (note: i havent changed anything just got ur code) without pressing C it will give me cash


Re: Some bugs. - Cypress - 18.09.2012

I don't see any reason of why it gives you cash. Since timer is not starting when you enter on the checkpoint, or is it?

Show me the OnPlayerEnterDynamicCP or look inside, maybe there's something wrong around you have missed.


Re: Some bugs. - thefatshizms - 18.09.2012

Ill give my onplayer keystate change if its any help

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_CROUCH)) {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, 379.0827,-65.4114,1001.5078)) {
            if(RobbedR == false)
            {
                countn[playerid]=12;
                dstimer[playerid]=SetTimerEx("Rob",1000,true,"i",playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "This store has been robbed recently. Please try again");
            }
            return 1;
        }
    }
    return true;
}
pawn Код:
public Rob(playerid)
{
    if(IsPlayerInDynamicCP(playerid, burgerrob))
    {
        countn[playerid]--;
        new string[128];
        format(string, sizeof(string), "Attempting robbery~n~~b~%i~n~~r~Stay in the checkpoint", countn[playerid]);
        TextDrawSetString(robbery, string);
        TextDrawShowForPlayer(playerid, robbery);
    }
    if(countn[playerid] <= 0)
    {
        if(IsPlayerInDynamicCP(playerid, burgerrob))
        {
            RobbedR = true;
            SetTimer("RR", 300000, false);
            GivePlayerMoney(playerid, random(50000));
            KillTimer(dstimer[playerid]);
            TextDrawHideForPlayer(playerid, robbery);
        }
    }
    return 1;
}
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == burgerrob) {
        SendClientMessage(playerid, COLOR_ORANGE, "Use the 'C' button To rob this store");
        return 1;
    }
    //my other code
    return 1;
}



Re: Some bugs. - TaLhA XIV - 18.09.2012

Sorry toooo late.


Re: Some bugs. - thefatshizms - 19.09.2012

wha?


Re: Some bugs. - Cypress - 20.09.2012

So what actually happens on when you enter to the checkpoint without pressing the 'C' key?