Checking score before spawning!
#1

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
Reply
#2

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.
Reply
#3

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

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

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;
}
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)