Need help (Checkpoint)
#1

Hello everybody, first of all thanks for taking care of this topic.

On topic:

I made a code wich allows a certain player capture a checkpoint, there's two teams, i kinda got an idea of how to prevent the player capping it thrice in a row or twice, unless the other team captures it he can cap it back, i mean in the script i got, the player can capture it as many times as he wants.. and i dont want that to happen.. so if anyone has a 'fix' for this it'd be very appreciated.

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{

    SendClientMessage(playerid, 0x00FF007A, "Wait 30 Seconds - To Caputre this Zone.");
    new namestr[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(namestr, sizeof(namestr), "[INFO]: %s[%d] Is trying to capture the checkpoint, Face him!", name, playerid);
    SendClientMessageToAll(0xFF80FFFF, namestr);
    timer = SetTimerEx("SetZone", 30000, false, "i", playerid);
    Checkpoint[playerid] = 1; //
    return 1;

}


public OnPlayerLeaveCheckpoint(playerid)
{
    if(Checkpoint[playerid] == 1)
    {
        SendClientMessage(playerid, 0x00FF007A, " You have left the checkpoint , You have failed to capture");
        new namestr[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(namestr, sizeof(namestr), "[INFO]: %s[%d] Failed to capture the checkpoint.", name, playerid);
        SendClientMessageToAll(red, namestr);
        KillTimer(timer);
        Checkpoint[playerid] = 0;
    }
    return 1;
}

forward SetZone(playerid);
public SetZone(playerid)
{
    SetPlayerScore(playerid,GetPlayerScore(playerid)+30 );
    GivePlayerMoney(playerid,30000);
    SendClientMessage(playerid, COLOR_BLUE,"You've captured the zone you received 30000 $ and 30 score");
    if(gTeam[playerid] == TEAM_HOMO)
    {
    SendClientMessageToAll (red, "Team Homo has captured the CheckPoint");
    }
    if(gTeam[playerid] == TEAM_NIGGA)
    {
    SendClientMessageToAll (red, "Team Nigga has captured the CheckPoint");
    }
    if Checkpoint[playerid] == 0);
    else{
    SendClientMessage(playerid, COLOR_RED, "[ERROR]: You already captured this zone");
    }
    return 1;
}
Reply
#2

Use a variable
Put this at the top of your script (under the includes)
pawn Код:
new Zone[Max_Players];
Now that variable will assign the zone to the team who captures it, it will be detection him by gTeam
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(Zone[playerid] == gTeam[playerid]) return SendClientMessage(playerid, 0x00FF007A, "This zone is already yours.");
    SendClientMessage(playerid, 0x00FF007A, "Wait 30 Seconds - To Caputre this Zone.");
    new namestr[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(namestr, sizeof(namestr), "[INFO]: %s[%d] Is trying to capture the checkpoint, Face him!", name, playerid);
    SendClientMessageToAll(0xFF80FFFF, namestr);
    timer = SetTimerEx("SetZone", 30000, false, "i", playerid);
    Checkpoint[playerid] = 1; //
    return 1;

}


public OnPlayerLeaveCheckpoint(playerid)
{
    if(Checkpoint[playerid] == 1)
    {
        SendClientMessage(playerid, 0x00FF007A, " You have left the checkpoint , You have failed to capture");
        new namestr[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(namestr, sizeof(namestr), "[INFO]: %s[%d] Failed to capture the checkpoint.", name, playerid);
        SendClientMessageToAll(red, namestr);
        KillTimer(timer);
        Checkpoint[playerid] = 0;
    }
    return 1;
}

forward SetZone(playerid);
public SetZone(playerid)
{
    SetPlayerScore(playerid,GetPlayerScore(playerid)+30 );
    GivePlayerMoney(playerid,30000);
    SendClientMessage(playerid, COLOR_BLUE,"You've captured the zone you received 30000 $ and 30 score");
    if(gTeam[playerid] == TEAM_HOMO)
    {
    SendClientMessageToAll (red, "Team Homo has captured the CheckPoint");
    }
    if(gTeam[playerid] == TEAM_NIGGA)
    {
    SendClientMessageToAll (red, "Team Nigga has captured the CheckPoint");
    }
    Zone[playerid] = gTeam[playerid];
    return 1;
}
P.S:
If the code doesn't work, contact me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)