A problem with my robbery system
#1

So basically when the first player does a robbery and finishes it out he gets the reward, the next player does a robbery, when it finishes out, the first player who did a robbery gets the next players reward..

So:
ID 0: Robbery - He gets both of ID 0's and ID 1's reward.
ID 1: Robbery - He gets nothing.

The code:

Old:
pawn Код:
forward HasRobbedStore(playerid);
forward HasRobbedStore2(playerid);

new HasRobbedStoreRecently[MAX_PLAYERS];

public HasRobbedStore(playerid)
{
    TogglePlayerControllable(playerid, 1);
    SetTimer("HasRobbedStore2", 300000, false);
    new string[128];
    new mrand = random(25000);
    new ID;
    format(string,sizeof(string),"Player %s(%d) has robbed $%i from a store.",PlayerName(ID),ID, mrand);
    SendClientMessageToAll(COL_WHITE, string);
    SetPlayerWantedLevel(ID, 1);
    GivePlayerMoney(ID, mrand);
    WantedColor(ID);
}
public HasRobbedStore2(playerid)
{
    HasRobbedStoreRecently[playerid] = 0;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_WALK && (IsPlayerInRangeOfPoint(playerid,3.0,355.0123,166.7394,1008.3793) && gTeam[playerid] == TEAM_CRIMINAL))
    {
    SendClientMessage(playerid, COL_WHITE, "You are now attempting to rob a store. Please wait for 30 seconds.");
    HasRobbedStoreRecently[playerid] = 1;
    SetTimer("HasRobbedStore", 30000, false);
    TogglePlayerControllable(playerid, 0);
    }
    return 1;
}
NEW:
pawn Код:
forward HasRobbedCityhall(playerid);
forward HasRobbedCityhall2(playerid);

new HasRobbedCityhallRecently[MAX_PLAYERS];

public HasRobbedCityhall(playerid)
{
    TogglePlayerControllable(playerid, 1);
    SetTimer("HasRobbedCityhall2", 300000, false);
    new string[128];
    new mrand = random(25000);
    new ID;
    format(string,sizeof(string),"Player %s(%d) has robbed $%i from the city hall.",PlayerName(ID),ID, mrand);
    SendClientMessageToAll(COL_WHITE, string);
    SetPlayerWantedLevel(ID, 1);
    GivePlayerMoney(ID, mrand);
    WantedColor(ID);
}
public HasRobbedCityhall2(playerid)
{
    HasRobbedCityhallRecently[playerid] = 0;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_WALK && (IsPlayerInRangeOfPoint(playerid,3.0,355.0123,166.7394,1008.3793) && gTeam[playerid] == TEAM_CRIMINAL))
    {
    SendClientMessage(playerid, COL_WHITE, "You are now attempting to rob the city hall. Please wait for 30 seconds.");
    HasRobbedCityhallRecently[playerid] = 1;
    SetTimerEx("HasRobbedCityhall", 30000, false,"i",playerid);
    TogglePlayerControllable(playerid, 0);
    }
}
Reply
#2

pawn Код:
SetTimerEx("HasRobbedStore", 30000, false,"i",playerid);
Reply
#3

New code:
pawn Код:
forward HasRobbedCityhall(playerid);
forward HasRobbedCityhall2(playerid);

new HasRobbedCityhallRecently[MAX_PLAYERS];

public HasRobbedCityhall(playerid)
{
    TogglePlayerControllable(playerid, 1);
    SetTimer("HasRobbedCityhall2", 300000, false);
    new string[128];
    new mrand = random(25000);
    new ID;
    format(string,sizeof(string),"Player %s(%d) has robbed $%i from the city hall.",PlayerName(ID),ID, mrand);
    SendClientMessageToAll(COL_WHITE, string);
    SetPlayerWantedLevel(ID, 1);
    GivePlayerMoney(ID, mrand);
    WantedColor(ID);
}
public HasRobbedCityhall2(playerid)
{
    HasRobbedCityhallRecently[playerid] = 0;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_WALK && (IsPlayerInRangeOfPoint(playerid,3.0,355.0123,166.7394,1008.3793) && gTeam[playerid] == TEAM_CRIMINAL))
    {
    SendClientMessage(playerid, COL_WHITE, "You are now attempting to rob the city hall. Please wait for 30 seconds.");
    HasRobbedCityhallRecently[playerid] = 1;
    SetTimerEx("HasRobbedCityhall", 30000, false,"i",playerid);
    TogglePlayerControllable(playerid, 0);
    }
}
Still doesnt work..

EDIT: Changed "ID" to "playerid", testing if it worked now.
EDIT: Abovesaid worked. Problem solved.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)