SA-MP Forums Archive
Return player to team after checkpoint - help - 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: Return player to team after checkpoint - help (/showthread.php?tid=398601)



Return player to team after checkpoint - help - Breilid - 10.12.2012

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;
}



Re: Return player to team after checkpoint - help - JaKe Elite - 10.12.2012

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..


Re: Return player to team after checkpoint - help - Breilid - 10.12.2012

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