Skin Selection
#1

Ok i'm trying to make a way for cops to pick there skins when they go on duty. How could i make a skin selection without having to use add player class, They duty up and if they haven't set a skin then they get to pick there skin by going through like a skin selection type deal, Almost like class slection but it's not class selection they use keys nshit to go through the skins and once they pick one they press another key and it sets the skin they choosed to there skin.

I'm trying to make this so they don't have do to F4 and kill to change the pd skin, so all they'd have to do is type a command and it bring them to thew skin selection.
Reply
#2

Maybe try doing it via this way...

pawn Код:
COMMAND:afk(playerid, params[])
{
SetPlayerSkin(playerid, SKINID);
    return 1;
}
I don't know how to make it any easier, if someone does, please help :3
Reply
#3

I want them to be able to view the skin before selecting it.
Reply
#4

They cant view the skin but you could save the skin they had, like
pawn Код:
new
    lSelSkin[MAX_PLAYERS] = {-1, ...};

COMMAND:selskin(playerid, params[]) {
    if(lSelSkin[playerid] == -1) {
        lSelSkin[playerid] = GetPlayerSkin(playerid); //saves their current skin
        SelectSkin(playerid); //calls the selection function
    } else {
        lSelSkin[playerid] = -1; //resets the variable => stops the timer
    }
}
A selection skin function can look like that, another good example is in the grandlarc gm
pawn Код:
forward SelectSkin(playerid);
public SelectSkin(playerid) {
    if(lSelSkin[playerid] != -1) {
        new
            skin,
            keys,
            leftright;
        GetPlayerKeys(playerid, keys, skin, leftright); //get the keys
        if(keys == KEY_ACCEPT) { //accept
            lSelSkin[playerid] = -1; //resets the variable
            return ; //stop
        } else if(keys == KEY_ABORT) { //abort
            SetPlayerSkin(playerid, lSelSkin[playerid]); //give his old skin back
            lSelSkin[playerid] = -1; //resets the variable
            return ; //stop
        }
        if(leftright != 0) { // not perfect since there are only 284 skins, in the 300 numbers
            skin = GetPlayerSkin(playerid);
            if(leftright < 0) {
                if(--skin == -1) {
                    skin = 299;
                }
            } else {
                if(++skin == 300) {
                    skin = 0;
                }
            }
            SetPlayerSkin(playerid, skin);
        } //recalls the code still abort / accept or disconnect
        SetTimerEx("SelectSkin", 250, false, "i", playerid);
    }
}
To stop the timer if the player leaves and to reset the variable
pawn Код:
//OnPlayerDisconnect
    lSelSkin[playerid] = -1;
Reply
#5

wow very strange !
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Rough code using YSI:

pawn Код:
#include <YSI\y_groups>
#include <YSI\y_classes>
#include <YSI\y_commands>

new
    Group:gGroupPolice,
    Group:gGroupCivilian,
    Group:gGroupCanBePolice;

public OnGameModeInit()
{
    // Create the groups.
    gGroupPolice = Group_Create("Police");
    gGroupCivilian = Group_Create("Civilian");
    gGroupCanBePolice = Group_Create("Off Duty");
   
    // Create the police skins for class selection.
    // Note that "Class_Add" and "Class_AddForGroup" can have up to 13 optional
    // weapons with ammo, including "WEAPON_ARMOUR" with armour amount.
    Class_AddForGroup(gGroupPolice, POLICE_SKIN, X, Y, Z, A, WEAPONS);
    // More go here.
   
    // Create the civilian skins.
    Class_AddForGroup(gGroupCivilian, CIVILIAN_SKIN, X, Y, Z, A, WEAPONS);
    // More go here.
   
    // Set the "/duty" command to only be used by people who can be police.
    // First disable the command for all players.
    Group_SetGlobalCommand(YCMD:duty, false);
    // Secondly enable it only for people in the group who can be police.
    Group_SetCommand(gGroupCanBePolice, YCMD:duty, true);
}

public OnPlayerLogin(playerid)
{
    // Or equivalent callback/code in your mode.
    // Set any players who CAN be police in to the "can be police" group.
    if (/* your code for can be police */)
    {
        Group_SetPlayer(gGroupCanBePolice, playerid, true);
    }
}

public OnPlayerConnect(playerid)
{
    // Add all players to the civilian group by default.
    Group_SetPlayer(gGroupCivilian, playerid, true);
}

YCMD:duty(playerid, params[], help)
{
    if (help)
    {
        // Display the help on this command.
        return SendClientMessage(playerid, 0xFF0000AA, "Allows a player to go on duty as a member of the police");
    }
    // You can use
   
    // Remove the player from the civilian group (as they're no longer a
    // civilian, so can't use those skins).
    Group_SetPlayer(gGroupCivilian, playerid, false);
   
    // Add the player as an on-duty police officer.
    Group_SetPlayer(gGroupPolice, playerid, true);
   
    // Instantly return the player to class selection to choose a new skin.  Now
    // that they have changed groups they will have a different selection of
    // skins available for them to choose.
    Class_ReturnToSelection(playerid);
}

I need to tweak something in y_classes as I've figured out why ReturnToSelection stopped working (happened when I moved to y_hooks from ALS), but if you use the SVN version later today this should be fine.
I didn't quite understand how the y_classes and y_groups worked by lookin at the thread where it mentions them. This made it easier for me to understand, Thank you ******. I'll be downloading the svn
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)