SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 04/10/2009, 08:15 PM   #1
Rickyboy30
Big Clucker
 
Join Date: Nov 2008
Posts: 150
Reputation: 0
Default Saving skins.

Hey,
I would like to know. Im using SeifAdmin,
I can set a player his skin by using /setskin, but if I do that and I relog, get killed my skin resets himself to the first skin I ever used.
Is there anyone to save your skin and when you login, you will login automaticly with that skin ?

Thanks
Rickyboy30 is offline  
Old 04/10/2009, 08:35 PM   #2
Virtual1ty
Banned
 
Join Date: Jun 2009
Location: Croatia (Hrvatska)
Posts: 734
Reputation: 102
Default Re: Saving skins.

i guess you could use somthing like this.. made it in a short while,, didnt tested:
pawn Code:
// Player Info
enum Info
{
    AdminLevel,
    Password[150],
    Cash,
    Warns,
    Jail,
    Logged,
    Mute,
    Skin,
    WarnReason1[128],
    WarnReason2[128],
    WarnReason3[128],
    IP[20],
};


//OnPlayerRegister:
public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
      new name[MAX_PLAYER_NAME], str[128], ip[15];
      GetPlayerName(playerid, name, sizeof name);
      GetPlayerIp(playerid, ip, sizeof ip);
      format(str, sizeof str, "/sAccounts/%s.seifadmin", name);
      new File:account = fopen(str, io_write);
      if (account)
        {
            strmid(AccountInfo[playerid][Password], password, 0, strlen(password), 255);
            AccountInfo[playerid][Cash] = GetPlayerMoney(playerid);
            new file[256];
            {
                format(file, sizeof file, "Password: %s\n", AccountInfo[playerid][Password]);
                {   fwrite(account, file); }
                format(file, sizeof file, "AdminLevel: %d\n", 0);
                {   fwrite(account, file); AccountInfo[playerid][AdminLevel] = 0; }
                format(file, sizeof file, "Cash: %d\n", AccountInfo[playerid][Cash]);
                {   fwrite(account, file); }
                format(file, sizeof file, "Skin: %d\n", AccountInfo[playerid][Skin]);
                {   fwrite(account, file); }
                format(file, sizeof file, "Warnings: %d\n",AccountInfo[playerid][Warns]);
                {   fwrite(account, file); }
                format(file, sizeof file, "WarnReason1: %s\n",AccountInfo[playerid][WarnReason1]);
                {   fwrite(account, file); }
                format(file, sizeof file, "WarnReason2: %s\n",AccountInfo[playerid][WarnReason2]);
                {   fwrite(account, file); }
                format(file, sizeof file, "WarnReason3: %s\n",AccountInfo[playerid][WarnReason3]);
                {   fwrite(account, file); }
                format(file, sizeof file, "IPAddress: %s\n",ip);
                {   fwrite(account, file); }
            }
            fclose(account);
            SendClientMessage(playerid, GREEN, "|- Account successfully registered. You can now login ( /login [password] ) -|");
        }
    }
    return 1;
}


//OnPlayerUpdateAccount
public OnPlayerUpdateAccount(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(AccountInfo[playerid][Logged] == 1)
        {
            new name[MAX_PLAYER_NAME], str[128];
          GetPlayerName(playerid, name, sizeof name);
          format(str, sizeof str, "/sAccounts/%s.seifadmin", name);
          new File:account = fopen(str, io_write);
          if (account)
            {
                AccountInfo[playerid][Cash] = GetPlayerMoney(playerid);
                new file[256];
                {
                    format(file, sizeof file, "Password: %s\n", AccountInfo[playerid][Password]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "AdminLevel: %d\n",AccountInfo[playerid][AdminLevel]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Cash: %d\n", AccountInfo[playerid][Cash]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Skin: %d\n", AccountInfo[playerid][Skin]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Warnings: %d\n",AccountInfo[playerid][Warns]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason1: %s\n",AccountInfo[playerid][WarnReason1]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason2: %s\n",AccountInfo[playerid][WarnReason2]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason3: %s\n",AccountInfo[playerid][WarnReason3]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "IPAddress: %s\n",AccountInfo[playerid][IP]);
                    {   fwrite(account, file); }
                }
                fclose(account);
            }
        }
    }
    return 1;
}

//OnPlayerLogin
public OnPlayerLogin(playerid, password[])
{
  new name[MAX_PLAYER_NAME], str[128];
  GetPlayerName(playerid, name, sizeof name);
    format(str, sizeof str, "/sAccounts/%s.seifadmin", name);
    new File:account = fopen(str, io_read);
    if (account)
    {
      new pass[256];
      new passres[256], value[256];
      fread(account, pass, sizeof pass);
      passres = GetFileString(pass);
      if (!strcmp("Password", passres))
        {
            value = GetFileValue(pass);
            strmid(AccountInfo[playerid][Password], value, 0, strlen(value), 150);
        }
        if (!strcmp(AccountInfo[playerid][Password], password, true))
        {
          while (fread(account, pass, 256))
            {
                passres = GetFileString(pass);
                if (!strcmp("AdminLevel", passres, true))
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][AdminLevel] = strval(value);
                }
                if (!strcmp("Cash", passres, true))
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][Cash] = strval(value);
                }
                if (!strcmp("Skin", passres, true))
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][Skin] = strval(value);
                }
        if (!strcmp("Warnings", passres, true))
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][Warns] = strval(value);
                }
                if (!strcmp("WarnReason1", passres, true))
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason1], value, 0, strlen(value), 128);
                }
                if (!strcmp("WarnReason2", passres, true))
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason2], value, 0, strlen(value), 128);
                }
            if (!strcmp("WarnReason3", passres, true))
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason3], value, 0, strlen(value), 128);
                }
            }
            fclose(account);
      AccountInfo[playerid][Logged] = 1;
        }
        else
        {
            SendClientMessage(playerid, RED, "Incorrect Password.");
        fclose(account);
        return 1;
        }
        GivePlayerMoney(playerid, AccountInfo[playerid][Cash]);
        format(str, sizeof str, "|- You have successfully logged in as %s -|", name);
        SendClientMessage(playerid, GREEN, str);
        printf("%s has logged in", name);
        if (AccountInfo[playerid][AdminLevel] > 0)
        {
        format(str, sizeof str, "| You are now logged in as a level %d admin |", AccountInfo[playerid][AdminLevel]);
            SendClientMessage(playerid, LIGHTGREEN, str);
            ViewCmds[playerid] = 0;
        }
    }
    return 1;
}

//...and OnPlayerSpawn:

public OnPlayerSpawn(playerid)
{
    if(AccountInfo[playerid][Logged] == 1)
    {
        if(AccountInfo[playerid][Skin] > 0) { SetPlayerSkin(playerid, AccountInfo[playerid][Skin]); }
    }
    return 1;
}
Virtual1ty is offline  
Old 04/10/2009, 08:50 PM   #3
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Saving skins.

Do you save the skin?
MenaceX^ is offline  
Old 04/10/2009, 09:20 PM   #4
Rickyboy30
Big Clucker
 
Join Date: Nov 2008
Posts: 150
Reputation: 0
Default Re: Saving skins.

Well, that's the problem, Idk how to save it lol
Rickyboy30 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Good Dini/Dudb tutorial for file saving and info saving for example score ect JoeDaDude Help Archive 2 07/02/2010 10:04 PM
[FilterScript] [FS] Skins DSK_Vyorel Filterscripts 3 10/01/2010 10:17 PM
[HELP] Saving user skins Matthew_Murdoch Help Archive 5 29/08/2009 01:14 PM
All skins Geekzor Help Archive 2 07/08/2009 08:38 PM
Same skins Geekzor Help Archive 5 05/08/2009 09:48 AM


All times are GMT. The time now is 10:01 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.