JobSkin -
Maky184 - 01.11.2017
How to make /equipment and that when I go again /equipment to give me back the old skin?
Re: JobSkin -
Arbico - 01.11.2017
You need to save the old skin in the player database
Here is an example. Don't forget to edit it.
PHP код:
#define Skin 30 //This is the skin you want the player to change to when he enters the command
new OldSkin[MAX_PLAYERS];
new Equipped[MAX_PLAYERS] = false;
CMD:equipment(playerid, params[]) {
if(Equipped[playerid] == true) {
SendClientMessage(playerid, 0x005500AA, "You have returned to your old clothes");
SetPlayerSkin(playerid, OldSkin[playerid]);
Equipped[playerid] = false;
}
else {
Equipped[playerid] = true;
OldSkin[playerid] = GetPlayerSkin(playerid);
SendClientMessage(playerid, 0x005500AA, "You have changed your clothes");
SetPlayerSkin(playerid, Skin);
}
return 1;
}
Re: JobSkin -
Maky184 - 01.11.2017
Tnx but....
(203) warning 213: tag mismatch
(203) if(Equipped[playerid] == true)
Re: JobSkin -
n00blek - 01.11.2017
Change true to 1
Re: JobSkin -
CXdur - 01.11.2017
Quote:
Originally Posted by Arbico
You need to save the old skin in the player database
Here is an example. Don't forget to edit it.
PHP код:
#define Skin 30 //This is the skin you want the player to change to when he enters the command
new OldSkin[MAX_PLAYERS];
new Equipped[MAX_PLAYERS] = false;
CMD:equipment(playerid, params[]) {
if(Equipped[playerid] == true) {
SendClientMessage(playerid, 0x005500AA, "You have returned to your old clothes");
SetPlayerSkin(playerid, OldSkin[playerid]);
Equipped[playerid] = false;
}
else {
Equipped[playerid] = true;
OldSkin[playerid] = GetPlayerSkin(playerid);
SendClientMessage(playerid, 0x005500AA, "You have changed your clothes");
SetPlayerSkin(playerid, Skin);
}
return 1;
}
|
You should probably distinguish arrays from databases. Arrays are a way to represent structured data in memory. Databases are a tool to store data on disk until you need to retrieve it.
If you'd like to use true/false instead of 0/1, you need to tag the variable with bool:, for instance (bool
kinChanged)
Also, the entire equipped variable is obsolete, you can simply use the OldSkin[playerid] variable for this (check if it's set, if not set it, you get the point).
Also, you should probably then reset the OldSkin[playerid] when the player disconnects or connects.
I created a small quick command so you can change to a skin you want, I haven't tested it though:
If you'd like to add this, you need to add SetPVarInt(playerid, "old_skin", -1); to OnPlayerConnect or disconnect,
if not it will not work properly (this is because CJ has skin 0).
Код:
CMD:equipment(playerid, params[])
{
new oldSkin = GetPVarInt(playerid, "old_skin");
if (oldSkin < 0)
{
new skin;
if (sscanf(params, "d", skin))
{
return SendClientMessage(playerid, -1, "Usage: {595252}/equipment (skin)");
}
else
{
if (skin == 65 || skin == 74 || skin < 0 || skin >= 312)
{
return SendClientMessage(playerid, -1, "The skin you specified is invalid!");
}
SetPVarInt(playerid, "old_skin", GetPlayerSkin(playerid));
SetPlayerSkin(playerid, skin);
}
}
else
{
SetPlayerSkin(playerid, oldSkin);
DeletePVar(playerid, "old_skin");
}
return 1;
}
You should be able to understand how to do it from mine and Arbico's code now.