Return player to team after checkpoint - help
#1

Hey, i tried to make a flyingschool system on my server. And when the player type /applylic i set the players team to another team and back when the test is done:
pawn Код:
CMD:applylic(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 4.0, -2032.6999,-117.5,1035.1999))
    new lastteam;
    lastteam = gTeam[playerid];
        {
            if(FlyingLic[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You already have a pilot license.");
            if(FlyingLic[playerid] == 0)
                {
                gTeam[playerid] = TEAM_FLIC;
                GivePlayerMoney(playerid, -2000);
                SendClientMessage(playerid, COLOR_BLUE, "You have starter San Firros flying test, go out to the hangar ann enter a testplane");
                }
            }
    return 1;
}
And when the player enter a "schoolplane" it starts some RaceCheckpoint. All this works find, but i want to set the player back to his team that hi was in before the test. so i tried:
pawn Код:
if(FlicC[playerid] == 36)
        {
        DisablePlayerRaceCheckpoint(playerid);
        new Float:health;
        new veh;
        veh = GetPlayerVehicleID(playerid);
        GetVehicleHealth(veh, health);
        if(health <700)
            {
            SendClientMessage(playerid,COLOR_RED,"You failed the Flyingtest,");
            SendClientMessage(playerid,COLOR_RED,"try agein!");
            }
        else
            {
            SendClientMessage(playerid,COLOR_RED,"Congratulations, you successed the Flyingtest ");
            SendClientMessage(playerid,COLOR_RED,"Licenses is now yours!");
            (FlyingLic[playerid] = 1);
            gTeam[playerid] = lastteam;
            }
        return 1;
        }
Get some error, and i don't know if this code will work. So is it possible to set the team back?
and is it a diffrent way then:

pawn Код:
CMD:applylic(playerid, params[])
{
    new lastteam;
    lastteam = gTeam[playerid];

        return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    gTeam[playerid] = lastteam;

        return 1;
}
Reply
#2

Yes there is a way.
Your variable is must be outside of command.
Put it somewhere near in #include.

and it must new lastteam[MAX_PLAYERS];

pawn Код:
new lastteam[MAX_PLAYERS];
now.

you must change

pawn Код:
lastteam

to

lastteam[playerid]
It is possible..
Reply
#3

Quote:
Originally Posted by Romel
Посмотреть сообщение
Yes there is a way.
Your variable is must be outside of command.
Put it somewhere near in #include.

and it must new lastteam[MAX_PLAYERS];

pawn Код:
new lastteam[MAX_PLAYERS];
now.

you must change

pawn Код:
lastteam

to

lastteam[playerid]
It is possible..
Thanks alot for the help! it worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)