18/04/2023 20:15
Hello, I made a prototype that you can adapt to your gamemode.
You can see more about the function GetPlayerKeys by clicking here.
Código PHP:
new selectingSkin[MAX_PLAYERS];
new skinIndex[MAX_PLAYERS];
CMD:teste(playerid)
{
selectingSkin[playerid] = !selectingSkin[playerid];
if(selectingSkin[playerid]) {
TogglePlayerControllable(playerid, false);
SendClientMessage(playerid, -1, "You activated skin selection, press < left or > right.");
}
else {
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid, true);
SendClientMessage(playerid, -1, "You have disabled the selection of skins.");
}
return 1;
}
public OnPlayerUpdate(playerid)
{
static
str[128],
keys, updown, leftright;
GetPlayerKeys(playerid, keys, updown, leftright);
if(selectingSkin[playerid])
{
switch(leftright)
{
case KEY_LEFT: {
skinIndex[playerid]--;
if(skinIndex[playerid] < 0)
skinIndex[playerid] = 311;
SetPlayerSkin(playerid, skinIndex[playerid]);
format(str, sizeof(str), "Current skin: %d", skinIndex[playerid]);
SendClientMessage(playerid, -1, str);
}
case KEY_RIGHT: {
skinIndex[playerid]++;
if(skinIndex[playerid] > 311)
skinIndex[playerid] = 0;
SetPlayerSkin(playerid, skinIndex[playerid]);
format(str, sizeof(str), "Current skin: %d", skinIndex[playerid]);
SendClientMessage(playerid, -1, str);
}
}
}
return 1;
}
You can see more about the function GetPlayerKeys by clicking here.