Help! Neither am I able to find the bugs in it nor do I see any errors in it.

Started by BABA1, Aug 22, 2016, 04:41 PM

Previous topic - Next topic

BABA1

Hello Everyone, I would like to entreat you guys to help me out.
I was trying to script the /saveskin thing.
Here's what I did:
skin <- array(100, null);
function onPlayerCommand(player, cmd, text)
{
 if(cmd=="changeskin")
 {
   if(!text) PrivMessage(player, "Error: try this instead: /changeskin <skin id>");
   else if(!player.IsSpawned) PrivMessage(player, "Error, You need to spawn first!"):
   else
   {
     player.Skin = ( IsNum(text) ? text.tointerger() : GetSkinID(text) );
   }
 }
 else if(cmd=="saveskin")
 {
  if(!player.IsSpawned) PrivMessage(player, "Error: You need to spawn before you make use of any commands!");
  else
  {
    MessagePlayer("You've successfully set your skin", player);
     skin[player.ID] = player.Skin;
  }
 }
 else if(cmd=="removeskin")
 {
 skin[player.ID] = null;
 }
}
 
function onPlayerSpawn(player)
{
  if(skin[player.ID]!=null)
{
PrivMessage(player, "You've spawned with the garments of your choice!");
player.Skin = skin[player.ID];
}
}

I would be really glad and grateful if you guys could help me out by illustrating some examples and explaining them in a decent way. :D

Regards,
BABA1

EK.IceFlake

What happened? I cant make out anything from your question. Do you want us to give you guidance to making /saveskin?

Xmair


Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Eva

Quote from: Xmair on Aug 22, 2016, 05:18 PMWhat is the actual error?
as the subjecttitle sais he doesnt see any error, and from what i get his script doesnt work :P

BABA1

Quote from: Xmair on Aug 22, 2016, 05:18 PMWhat is the actual error?

There's no error but it doesn't seem to work at all.
To be more precise, It was supposed to work as soon as one spawns but it doesn't work in my case.

BABA1

BUMPING. Sorry but I had to. I want someone to check out my snippet and see if it works on theirs since it doesn't work in my case.

Mötley

Well I can not test. But I really looked over your code..
I noticed an issue with your array.
I also figured I would change the entire validations to see what that will do for you.

:P Maybe help update the topic for you as well and or fix it.

skin <- array(GetMaxPlayers(), 0);

function onPlayerCommand(player, cmd, text) {
    if(cmd=="changeskin") {
       if(!text) {
          PrivMessage(player, "Error: try this instead: /changeskin <skin id>");
          return true;
       }
       
       if(!player.IsSpawned) {
           PrivMessage(player, "Error, You need to spawn first!"):
           return true;
       }
           player.Skin = ( IsNum(text) ? text.tointerger() : GetSkinID(text) );
           return true;
    }
   
    if(cmd=="saveskin") {
       if(!player.IsSpawned) {
          PrivMessage(player, "Error: You need to spawn before you make use of any commands!");
          return true;
       }

       MessagePlayer("You've successfully set your skin", player);
       skin[player.ID] = player.Skin;
       return true;
     }
     
     if(cmd=="removeskin") {
          skin[player.ID] = null;
           return true;
     }
 
    //Just an error return for anything else
    MessagePlayer("Invalid skin command", player);
 
  return false;
}