Skin select.
#1

Hi SA-MP Community,
I want to do something like when a player clicks on a skin to spawn, (On the skin selection part) for example, for STAT skin a player must have 2000 or more score. So how Should I script it?
My Pawn Code:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerInterior(playerid,14);
    SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
    SetPlayerFacingAngle(playerid, 270.0);
    SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
    SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
    SetPlayerTeamFromClass(playerid, classid);
    switch(classid)
    {
    case 0..1: GameTextForPlayer(playerid, "~y~~h~STAT", 5000, 6);
    case 2: GameTextForPlayer(playerid, "~b~~h~SWAT", 5000, 6);
    case 3: GameTextForPlayer(playerid, "ARMY", 5000, 6);
    case 4..12: GameTextForPlayer(playerid, "~b~POLICE", 5000, 6);
    case 13..22: GameTextForPlayer(playerid, "~w~CIVILIAN", 5000, 6);
    case 23: GameTextForPlayer(playerid, "~l~~w~HITMAN", 5000, 6);
    case 24: GameTextForPlayer(playerid, "~w~MECHANIC", 5000, 6);
    case 25: GameTextForPlayer(playerid, "~g~PARAMEDIC", 5000, 6);
    }
    return 1;
}
Waiting for replies.....
Reply
#2

OK, using
Quote:

y_classes:

At the top:

pawn Code:

Quote:

#include <YSI\y_classes>
#include <YSI\y_groups>

Код:
new
    Group:gHighScoreGroup;


In OnGameModeInit:
pawn Code:

Код:
gHighScoreGroup = Group_Create("Over 350"); // Create the group with a description. and score for that group of skins... As you request...

Class_Add(all, skin, info); // Replace your normal skin selection with this.
// Create a class which only people in one group can use.
Class_AddForGroup(gHighScoreGroup, rest, of, info);
and.....

pawn Code:

Код:
stock GivePlayerScore(playerid, score)
{
    // Add the score to their current score.
    score += GetPlayerScore(playerid);
    SetPlayerScore(playerid, score);
    if (score >= 350)
    {
        Group_SetPlayer(gHighScoreGroup, playerid, true); // High score, add them to the group.
    }
    else
    {
        Group_SetPlayer(gHighScoreGroup, playerid, false); // Low score, remove them from the group.
    }
}
Unlike other solutions this will actually remove the skin entirely from the class selection for other people, not just refuse to let them select it.
Reply
#3

Quote:
Originally Posted by Vladamir
Посмотреть сообщение
OK, using

At the top:

pawn Code:


Код:
new
    Group:gHighScoreGroup;


In OnGameModeInit:
pawn Code:

Код:
gHighScoreGroup = Group_Create("Over 350"); // Create the group with a description. and score for that group of skins... As you request...

Class_Add(all, skin, info); // Replace your normal skin selection with this.
// Create a class which only people in one group can use.
Class_AddForGroup(gHighScoreGroup, rest, of, info);
and.....

pawn Code:

Код:
stock GivePlayerScore(playerid, score)
{
    // Add the score to their current score.
    score += GetPlayerScore(playerid);
    SetPlayerScore(playerid, score);
    if (score >= 350)
    {
        Group_SetPlayer(gHighScoreGroup, playerid, true); // High score, add them to the group.
    }
    else
    {
        Group_SetPlayer(gHighScoreGroup, playerid, false); // Low score, remove them from the group.
    }
}
Unlike other solutions this will actually remove the skin entirely from the class selection for other people, not just refuse to let them select it.
Good you just copied from here. :P

EDIT: I am not satisfied with this. Any other Reply?
Reply
#4

Quote:

If you can't say it better than someone else, quote those who said it best.

I would fix the problem EXACTLY as described above. Hopefully it helped you.
Reply
#5

How do you want it ?

Show the class in the selection and print "Not enough score points"
Or dont show the class

For the first you only need to add some lines in OnPlayerRequestSpawn
But for the second you need to modify OnPlayerRequestClass like y_classes does it (afaik its the only system released like that, although the theory behind it is quite simple)
Reply
#6

pawn Код:
new Team[MAX_PLAYERS] = -1;

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerInterior(playerid,14);
    SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
    SetPlayerFacingAngle(playerid, 270.0);
    SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
    SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
    SetPlayerTeamFromClass(playerid, classid);
    switch(classid)
    {
        case 0..1:
        {
            GameTextForPlayer(playerid, "~y~~h~STAT", 5000, 6);
            Team[playerid] = 1;
        }
        case 2:
        {
            GameTextForPlayer(playerid, "~b~~h~SWAT", 5000, 6);
            Team[playerid] = 2;
        }
        case 3:
        {
            GameTextForPlayer(playerid, "ARMY", 5000, 6);
            Team[playerid] = 3;
        }
        case 4..12:
        {
            GameTextForPlayer(playerid, "~b~POLICE", 5000, 6);
            Team[playerid] = 4;
        }
        case 13..22:
        {
            GameTextForPlayer(playerid, "~w~CIVILIAN", 5000, 6);
            Team[playerid] = 5;
        }
        case 23:
        {
            GameTextForPlayer(playerid, "~l~~w~HITMAN", 5000, 6);
            Team[playerid] = 6;
        }
        case 24:
        {
            GameTextForPlayer(playerid, "~w~MECHANIC", 5000, 6);
            Team[playerid] = 7;
        }
        case 25:
        {
            GameTextForPlayer(playerid, "~g~PARAMEDIC", 5000, 6);
            Team[playerid] = 8;
        }
    }
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    switch(Team[playerid])
    {
        case 1: //Team STAT
        {
            if(GetPlayerScore(playerid) < 2000)
            {
                SendClientMessage(playerid, 0xCC0000AA, "You don't have the required score to play this team!");
                return 0; //this will stop them from spawning
            }
        }
    }
    return 1;
}
Basically, we set their team in the class selection then check it when they try to spawn. If they don't have the required scored it will say no thanks you can't spawn.
Reply
#7

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
pawn Код:
new Team[MAX_PLAYERS] = -1;

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerInterior(playerid,14);
    SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
    SetPlayerFacingAngle(playerid, 270.0);
    SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
    SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
    SetPlayerTeamFromClass(playerid, classid);
    switch(classid)
    {
        case 0..1:
        {
            GameTextForPlayer(playerid, "~y~~h~STAT", 5000, 6);
            Team[playerid] = 1;
        }
        case 2:
        {
            GameTextForPlayer(playerid, "~b~~h~SWAT", 5000, 6);
            Team[playerid] = 2;
        }
        case 3:
        {
            GameTextForPlayer(playerid, "ARMY", 5000, 6);
            Team[playerid] = 3;
        }
        case 4..12:
        {
            GameTextForPlayer(playerid, "~b~POLICE", 5000, 6);
            Team[playerid] = 4;
        }
        case 13..22:
        {
            GameTextForPlayer(playerid, "~w~CIVILIAN", 5000, 6);
            Team[playerid] = 5;
        }
        case 23:
        {
            GameTextForPlayer(playerid, "~l~~w~HITMAN", 5000, 6);
            Team[playerid] = 6;
        }
        case 24:
        {
            GameTextForPlayer(playerid, "~w~MECHANIC", 5000, 6);
            Team[playerid] = 7;
        }
        case 25:
        {
            GameTextForPlayer(playerid, "~g~PARAMEDIC", 5000, 6);
            Team[playerid] = 8;
        }
    }
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    switch(Team[playerid])
    {
        case 1: //Team STAT
        {
            if(GetPlayerScore(playerid) < 2000)
            {
                SendClientMessage(playerid, 0xCC0000AA, "You don't have the required score to play this team!");
                return 0; //this will stop them from spawning
            }
        }
    }
    return 1;
}
Basically, we set their team in the class selection then check it when they try to spawn. If they don't have the required scored it will say no thanks you can't spawn.
What if I did these classes with 2000 or more score only accessible with a admin license permit?
How should I script a Command for it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)