#if defined credit
/saveskin /useskin /dontuseskin
#endif
// ====[iNCLUDE]====
#include <a_samp>
#include a_mysql //mysql R6
#include zcmd
#include sscanf2
new skinid, query[512];
CMD:saveskin(playerid,params[]) {
if(sscanf(params,\"i\",skinid)) return SendClientMessage(playerid,0xff0000AA,\"/saveskin <skin id 0-300>\");
if(skinid < 0 && skinid > 300) return SendClientMessage(playerid,0xff0000AA,\"Hiba: Skin id csak 0 és 300 között lehet\");
SetPVarInt(playerid,\"SkinID\",skinid);
format(query, sizeof(query), \"UPDATE `Skin` SET SkinID = \'%s\' WHERE Name = \'%s\';\", skinid, pName(playerid));
mysql_query(query);
SendClientMessage(playerid,0xff0000AA,\"[skin]Karakter elmentve. Betöltés: /useskin\");
return 1;
}
CMD:useskin(playerid,params[]) {
SendClientMessage(playerid,0xff0000AA,\"[skin]Karakter betöltve\");
SetPlayerSkin(playerid, GetPVarInt(playerid,\"SkinID\"));
return 1;
}
CMD:dontuseskin(playerid,params[]) {
SendClientMessage(playerid,0xff0000AA,\"\");
DeletePVar(playerid,\"SkinID\");
format(query, sizeof(query), \"UPDATE `Skin` SET SkinID = \'-1\' WHERE Name = \'%s\';\", pName(playerid));
mysql_query(query);
return 1;
}
public OnPlayerConnect(playerid) {
new rows[128];
format(query, sizeof(query), \"SELECT `SkinID` FROM `Skin` WHERE Name = \'%s\';\", pName(playerid));
mysql_query(query);
mysql_store_result();
mysql_fetch_row(rows);
sscanf(rows, \"p<|>i\", skinid);
SetPVarInt(playerid, \"SkinID\", skinid);
mysql_free_result();
return 1;
}
public OnPlayerDisconnect(playerid, reason) {
skinid = GetPVarInt(playerid, \"SkinID\");
format(query, sizeof(query), \"UPDATE `Skin` SET SkinID = \'%s\' WHERE Name = \'%s\';\", skinid, pName(playerid));
mysql_query(query);
return 1;
}
public OnPlayerSpawn(playerid) {
SendClientMessage(playerid, 0xff0000AA,\"[skin]Karaktered betöltve. Ha esetleg nincs mentve /saveskin\");
SetPlayerSkin(playerid, GetPVarInt(playerid,\"SkinID\"));
return 1;
}
stock pName(playerid) {
new name[24];
GetPlayerName(playerid,name,24);
return name;
}
/* MYSQL Tábla
CREATE TABLE `Skin` (
`Name` varchar(24) NOT NULL,
`SkinID` int(11) NOT NULL,
PRIMARY KEY (`Name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
*/
Nem teszteltem de elvileg jó.