Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <y_ini>
- /* Skin Dialog + SAVING INI
- by
- Private200 */
- // Defining the path where the user accounts will go
- #define PATH "/Skin/%s.ini"
- // Defining the user Information script-related
- enum pInfo
- {
- pSkin
- }
- //=======================[Colors]====================
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- //=======================[Shortcuts]====================
- #define SCM SendClientMessage
- //=======================[Defines]====================
- new CanChangeSkin[MAX_PLAYERS];
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("UserSkin",PlayerInfo[playerid][pSkin]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- format(string, sizeof(string), PATH, playername);
- return string;
- }
- /*Credits to Dracoblue*/
- stock udb_hash(buf[]) {
- new length=strlen(buf);
- new s1 = 1;
- new s2 = 0;
- new n;
- for (n=0; n<length; n++)
- {
- s1 = (s1 + buf[n]) % 65521;
- s2 = (s2 + s1) % 65521;
- }
- return (s2 << 16) + s1;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Skin FS by Private200");
- print("--------------------------------------\n");
- return 1;
- }
- COMMAND:changeskin(playerid, cmdtext[])
- {
- if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_LIGHTBLUE, "You must be an admin to use this command.");
- if(CanChangeSkin[playerid] == 0)
- {
- ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_INPUT, "{33CCFF}Skins", "{FFFFFF}We allow you to change your skin by\n{FFFFFF}typing below the skin ID you want.\n{FF0000}(AVAILABLE ARE FROM 0-299):", "Request", "Close");
- }
- else
- {
- SendClientMessage(playerid, COLOR_LIGHTBLUE, "You've changed your skin already in these last 10 seconds. Please wait some more time.");
- return 0;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 5000)
- {
- if(response)
- {
- new skinid, message[64];
- skinid = strval(inputtext);
- if(skinid < 0 || skinid > 299)
- {
- SendClientMessage(playerid, 0xFFFFFFFF, "The skin ID entered is not from 0 to 299");
- }
- else
- {
- SetPlayerSkin(playerid, skinid);
- format(message, sizeof(message), "We've provided you with the skin ID %d.", skinid);
- PlayerInfo[playerid][pSkin] = skinid;
- ChangingSkin(playerid);
- SendClientMessage(playerid, 0xFFFFFFFF, message);
- }
- }
- return 1;
- }
- return 0;
- }
- stock ChangingSkin(playerid)
- {
- SetTimer("SkinChangerTimer", 10000, false);
- CanChangeSkin[playerid] = 1;
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- }
- else
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"UserSkin", 0);
- INI_Close(File);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"UserSkin",PlayerInfo[playerid][pSkin]);
- INI_Close(File);
- return 1;
- }
- forward SkinChangerTimer(playerid);
- public SkinChangerTimer(playerid)
- {
- SendClientMessage(playerid, COLOR_LIGHTBLUE, "You're now available to change your skin again.");
- CanChangeSkin[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement