Elite Square
Would you like to react to this message? Create an account in a few clicks or log in to continue.

SetScale command

3 posters

Go down

SetScale command Empty SetScale command

Post  Wound Sat Jan 05, 2013 6:23 pm

well I've been trying to make this addon that basically sets someone's scale with a server command, and it isn't loading into my addons list.

Code:

package setScale
{
   function servercmdsetscale(%client,%name,%scale,%target)
{
   if(%client.issuperadmin && isobject(%target = findclientbyname(%name).player))
{
   if(getwordcount(%setscale) != 3)
{
      warn("/c3 Invalid Scale!")
      return false;
}
   %target.setscale(%scale);
   return true;
}
   return false;
}
      parent::servercmdsetscale(%client,%name,%scale,%target)
}
activatepackage(setscale);
Wound
Wound
Blocklandian

Posts : 16
Join date : 2013-01-01
Age : 25
Location : USA

Back to top Go down

SetScale command Empty Re: SetScale command

Post  Meshiest Sat Jan 05, 2013 7:43 pm

for players it is
%playerobject.setPlayerScale(%scale);

also, you don't have to parent the function unless it already exists...

Untested Code:
Code:

function servercmdRescale(%client,%x,%y,%z)
{
    if(!isObject(%client.player) || %x > 5 || %y > 5 || %z > 5) //checking for player and checking for sizes
          return;
    %client.player.setPlayerScale(%x SPC %y SPC %z); //setting player's scale
}
this will set the users scale to "x y z", however, if what you want to make it find other players
Code:

function servercmdScale(%client,%target,%x,%y,%z)
{
    if(!isObject(%client.player) || !isObject(%target = findclientbyname(%target).player) || !%client.isSuperAdmin)
          return;
    servercmdrescale(%target.client,%x,%y,%z);
}
OR, how you want it:
Code:

function servercmdScale(%client,%target,%scale)
{
    if(!isObject(%client.player) || !isObject(%target = findclientbyname(%target).player) || !%client.isSuperAdmin)
          return;
    servercmdrescale(%target.client,%scale,%scale,%scale);
}

Reviewing your code:
Code:
package setScale //Un needed, but ok
{
  function servercmdsetscale(%client,%name,%scale,%target) //What is target for ? you set it to the player?
{
  if(%client.issuperadmin && isobject(%target = findclientbyname(%name).player)) //Yes
{
  if(getwordcount(%setscale) != 3) //This wont work because setScale is not a variable
{
      warn("/c3 Invalid Scale!") //This will only tell the console, not the client, also "/c3" wont work in warn, and it is "\c3" backslash is for excape codes (like \" or \\ for " or \)
      return false; //returning false is un-needed, but ok?
}
  %target.setscale(%scale); //setScale will not work on the player, and %scale is one variable, so you might want to do (%scale SPC %scale SPC %scale) for "scale scale scale"
  return true;
}
  return false;
}
      parent::servercmdsetscale(%client,%name,%scale,%target) //needs semicolon, and is un-needed because it is out of the function
} //at the end of packages, because they are objects, they need semicolons and braces
activatepackage(setscale);

make sure you properly package your addon (meaning server.cs and description.txt)

Meshiest
Blocklandian

Posts : 68
Join date : 2013-01-02
Age : 26
Location : The Internet

http://marblemodz.forumotion.com

Back to top Go down

SetScale command Empty Re: SetScale command

Post  Wound Sat Jan 05, 2013 9:08 pm

Thank you.

how would this work?

Code:
function servercmdSetScale(%client,%target,%x,%y,%z)
{
    if(!isObject(%client.player) || !isObject(%target = findclientbyname(%target).player) || !%client.isSuperAdmin)
          return;
    servercmdrescale(%target.client,%x,%y,%z);
           return messageClient(%client, '', '\c4%1\c3s scale has been changed!', %player.name);
{
   else
   {
          commandToClient(%client, 'centerPrint', "\c4/SetScale \c5is currently unavailable for players of your status.", 4);
      }
   }
}
Wound
Wound
Blocklandian

Posts : 16
Join date : 2013-01-01
Age : 25
Location : USA

Back to top Go down

SetScale command Empty Re: SetScale command

Post  Meshiest Sat Jan 05, 2013 10:48 pm

Wound wrote:Thank you.

how would this work?

Code:
function servercmdSetScale(%client,%target,%x,%y,%z)
{
    if(!isObject(%client.player) || !isObject(%target = findclientbyname(%target).player) || !%client.isSuperAdmin)
          return;
    servercmdrescale(%target.client,%x,%y,%z);
           return messageClient(%client, '', '\c4%1\c3s scale has been changed!', %player.name);
{
   else
   {
          commandToClient(%client, 'centerPrint', "\c4/SetScale \c5is currently unavailable for players of your status.", 4);
      }
   }
}
did you test it?

rescale doesn't exist
%player doesnt exist
%player.name isn't valid, should be %client.name
is %player.name even needed?
Also, I use %client.centerprint("Text"@%variable@"moretext",%time); instead of commandtoclient....

Meshiest
Blocklandian

Posts : 68
Join date : 2013-01-02
Age : 26
Location : The Internet

http://marblemodz.forumotion.com

Back to top Go down

SetScale command Empty Re: SetScale command

Post  Innocent Sat Jan 05, 2013 11:08 pm

There you go :P

Code:
function servercmdSetPlayerScale(%cl,%target,%x,%y,%z)
{
    if(%cl.isadmin)
    {
        %targetplayer = findclientbyname(%target).player;
        %targetplayer.setscale(%x SPC %y SPC %z);
        %cl.chatmessage("<color:00FF00>"@%targetplayer.client.name@"'ve been resized to "@%x SPC %y SPC %z);
        %targetplayer.client.chatmessage("<color:00FF00>You've just been resized by an admin to: "@%x SPC %y SPC %z);
    }
    else
    {
        %cl.chatmessage("Only admins can use this function.");
    }
}


Last edited by Innocent on Sat Jan 05, 2013 11:51 pm; edited 1 time in total (Reason for editing : Forgot a " before @)
Innocent
Innocent
Blocklandian

Posts : 17
Join date : 2012-12-31
Age : 27
Location : Montreal

Back to top Go down

SetScale command Empty Re: SetScale command

Post  Meshiest Sun Jan 06, 2013 12:02 am

Innocent wrote:There you go Razz

Code:
-snip-

things that don't matter, but make things faster
%target = findclientbyname(%target).player
and
"\c2" == "<color:00ff00>"

also:
I just tested setScale and setPlayerScale, they are the same Razz but setPlayerScale was made for the events

Meshiest
Blocklandian

Posts : 68
Join date : 2013-01-02
Age : 26
Location : The Internet

http://marblemodz.forumotion.com

Back to top Go down

SetScale command Empty Re: SetScale command

Post  Innocent Sun Jan 06, 2013 12:34 am

Just wanted to be precise so everybody understand ;)
Also, I just have the habit to use <color:Whatever>.. Made a topic about it :)
Innocent
Innocent
Blocklandian

Posts : 17
Join date : 2012-12-31
Age : 27
Location : Montreal

Back to top Go down

SetScale command Empty Re: SetScale command

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum