SA-MP Forums Archive
Ensuring XP requirement before spawning - 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: Ensuring XP requirement before spawning (/showthread.php?tid=655416)



Ensuring XP requirement before spawning - div - 20.06.2018

Hello, i'm trying to make an XP requirement...



How to check if the player has enough XP or not?


if(pInfo[playerid][pXP] <= 9999)
return SendClientMessage(playerid, -1, "{FF0000}[ERROR]{FFFFFF} You do not have enough XP to join this class.");
else

//REST CODE


But idk where to put it under.. which callback..


Re: Ensuring XP requirement before spawning - CodeStyle175 - 20.06.2018

do you even understand what you want to do?


Re: Ensuring XP requirement before spawning - div - 20.06.2018

I'm working on a CnR gamemode, I want to make a requirement for classes, a bar of XP, for like 10k, if they have 10k+ XP, they can join that CLASS(like ARMY), if not a msg will be shown "YOU DO NOT MEET THE XP REQUIREMENT"


Re: Ensuring XP requirement before spawning - div - 21.06.2018

DAYUM BUMP, PLEASE HELP..


Re: Ensuring XP requirement before spawning - AgusZ - 21.06.2018

Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid); 
    return 1;
}
Код:
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        if(pInfo[playerid][pXP] <= 9999)
        return SendClientMessage(playerid, -1, "{FF0000}[ERROR]{FFFFFF} You do not have enough XP to join this class.");
    }
    else if(classid == 1)
    {
       if(pInfo[playerid][pXP] <= 0)
       return SendClientMessage(playerid, -1, "{FF0000}[MESSAGE]{FFFFFF} You joined this class.");
    }

}



Re: Ensuring XP requirement before spawning - div - 21.06.2018

Not really working, i feel like it should be under OnPlayerRequestSpawn..

Any function which can prevent a player from spawning?


Re: Ensuring XP requirement before spawning - Jyothiranand - 21.06.2018

Write downside onplayerrequestspawn
if(classid == something)
if(pInfo[playerid][pXP]<9999)
SendClientMessage(playerid, red, "you have joined army");
else
return 0;