SA-MP Forums Archive
Checking score 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: Checking score before spawning! (/showthread.php?tid=473576)



Checking score before spawning! - LeeXian99 - 03.11.2013

So, I'm not quite good in this stuff, I'm not sure where to put, so I will give out some
pawn Код:
public
so you can know and tell me where should I put.

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(playerid);
    if(gTeam[playerid] == CIVILIAN)
    {
        new Random = random(sizeof(RandomCivilianSpawn));
        SetPlayerPos(playerid, RandomCivilianSpawn[Random][0], RandomCivilianSpawn[Random][1], RandomCivilianSpawn[Random][2]);
        SetPlayerFacingAngle(playerid, RandomCivilianSpawn[Random][3]);
    }
    else if(gTeam[playerid] == POLICE)
    {
        SetPlayerPos(playerid, -1593.4480,716.3574,-5.2422);
    }
    else if(gTeam[playerid] == FBI)
    {
        SetPlayerPos(playerid,-2453.3762,503.8329,30.0804);
    }
    else if(gTeam[playerid] == ARMY)
    {
        SetPlayerPos(playerid,-1394.5947,300.0893,7.1875);
    }
    return 1;
}
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid,classid);
    SetPlayerPos(playerid, -1969.2195,137.5724,27.6875);
    SetPlayerCameraPos(playerid, -1977.5739,138.0104,27.6875);
    SetPlayerCameraLookAt(playerid,-1977.5739,138.0104,27.6875);
    SetPlayerFacingAngle(playerid,90.2709);
   
    switch(classid)
    {
        case 0, 1:
        {
            GameTextForPlayer(playerid, "~w~Civilian!", 3000,5);
        }
        case 2, 3:
        {
            GameTextForPlayer(playerid, "~b~Police!", 3000, 5);
        }
        case 4:
        {
            GameTextForPlayer(playerid, "~b~FBI!", 3000, 5);
        }
        case 5:
        {
            GameTextForPlayer(playerid, "~p~Army!", 3000, 5);
        }
    }
    return 1;
}
Thanks in advance if it works


Re: Checking score before spawning! - Konstantinos - 03.11.2013

https://sampwiki.blast.hk/wiki/OnPlayerRequestSpawn

Use this callback instead, it's called when a player tries to spawn so check their score and if it's not enough in order to spawn, return 0 to prevent the player from being spawned.


Re: Checking score before spawning! - Beckett - 03.11.2013

What do you exactly wanna do I don't get it.


Re: Checking score before spawning! - LeeXian99 - 03.11.2013

So what should I do, like to have 1000 score to join army classes?


Re: Checking score before spawning! - Konstantinos - 03.11.2013

It should work.

pawn Код:
public OnPlayerRequestSpawn( playerid )
{
    if( gTeam[ playerid ] == ARMY && GetPlayerScore( playerid ) < 1000 )
    {
        SendClientMessage( playerid, -1, "You need atleast 1000 score in order to join Army team.");
        return 0;
    }
    return 1;
}



Re: Checking score before spawning! - LeeXian99 - 03.11.2013

Alright thanks, it helps me alot in the future like I add class on my gamemode