Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: KAKAN on Sep 06, 2015, 06:11 AM

Title: saveskin, removeskin
Post by: KAKAN on Sep 06, 2015, 06:11 AM
Credits:- @KAKAN aka me, @soulshaker (for changeskin cmd)

ChangeSkin cmd:-
if ( cmd == "changeskin" )
    {
        if ( !player.IsSpawned ) MessagePlayer( "[#EE3B3B]You have to be spawned to use this command.", player );
        else if ( !text ) MessagePlayer( "[#FFFFFE]Syntax:- /" + cmd + "[#EE3B3B] <ID/SkinName>", player );
        else if( IsNum(text) )
 {
  player.Skin = text.tointeger();
         MessagePlayer( "[#66CD00]Skin changed to: " + GetSkinName( player.Skin ), player );
        }
 else
         {
  local skin_id = GetSkinID(text);
         if (skin_id < 0) MessagePlayer( "[#EE3B3B]Could not identify the specified skin name.", player );
  else
         {
  player.Skin = skin_id;
  MessagePlayer( "[#66CD00]Skin changed to: " + GetSkinName( player.Skin ), player );
  }
  }
    }

Needed things
class SkinClass
{
skina = false;
skin = null;
}

function onScriptLoad()
{
sarray <- array(GetMaxPlayers(), null)
}

function onPlayerJoin(player)
{
sarray[ player.ID ] = SkinClass(player.Name); //Correct me if I'm wrong here
}

function onPlayerPart(player,reason)
{
sarray[player.ID] = null;
}

function onPlayerSpawn(player)
{
if ( sarray[ player.ID ].skina )
{
local skinr = sarray[ player.ID ].skin
local skin = GetSkinID(skinr)
player.Skin = skin.tointeger()
}
}

AND ATLAST The COmmands:-
else if ( cmd == "saveskin" )
{
local skiin = GetSkinName( player.Skin );
sarray[ player.ID ].skina = true;
sarray[ player.ID ].skin = skiin;
MessagePlayer(">> You have saved your current skin for next spawn/s.",player);
}

else if ( cmd == "removeskin" )
{
sarray[ player.ID ].skina = false;
MessagePlayer(">> You have removed your current saved skin for next spawn/s.",player);
}
Title: Re: saveskin, removeskin
Post by: FinchDon on Sep 06, 2015, 06:12 AM
Can i ask what this system do??
Title: Re: saveskin, removeskin
Post by: KAKAN on Sep 06, 2015, 07:42 AM
Your head!
This system will save the skin for the next spawn, so u can spawn with your favorite skin unless u leave the server
Title: Re: saveskin, removeskin
Post by: FinchDon on Sep 06, 2015, 07:44 AM
haha bug when i spawn while saveskin it doesnot give savedskin
Title: Re: saveskin, removeskin
Post by: KAKAN on Sep 06, 2015, 07:49 AM
DOes it give any error, NO
You have to edit the saveskin and removeskin according to your system, Have u added the playerclass?
[mergedate]1441525719[/mergedate]
Because this is working on mine
Title: Re: saveskin, removeskin
Post by: FinchDon on Sep 06, 2015, 07:55 AM
ya i added
Title: Re: saveskin, removeskin
Post by: KAKAN on Sep 06, 2015, 08:42 AM
So, it works now?
If no, then post your code
Title: Re: saveskin, removeskin
Post by: FinchDon on Sep 06, 2015, 09:02 AM
I miss the OnPlayerJoin
Title: Re: saveskin, removeskin
Post by: KAKAN on Sep 06, 2015, 09:51 AM
lol... You can add it on your own PlayerClass
Title: Re: saveskin, removeskin
Post by: Xmair on Sep 06, 2015, 11:49 AM
First of all, Nice work.
Secondly, I want my credits, I helped you in saveskin xD
Title: Re: saveskin, removeskin
Post by: KAKAN on Sep 06, 2015, 11:56 AM
:P u didn't, the one u gave didn't work, so i tried another idea to save the skin NAME then change the SKIN NAME to SKIN ID while player spawns and set the player SKIN to the requested SKIN ID