SetScale command
3 posters
Elite Square :: Blockland :: Coding Help
Page 1 of 1
SetScale command
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- Blocklandian
- Posts : 16
Join date : 2013-01-01
Age : 25
Location : USA
Re: SetScale command
for players it is
%playerobject.setPlayerScale(%scale);
also, you don't have to parent the function unless it already exists...
Untested Code:
Reviewing your code:
make sure you properly package your addon (meaning server.cs and description.txt)
%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
}
- 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);
}
- 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)
Re: SetScale command
Thank you.
how would this work?
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- Blocklandian
- Posts : 16
Join date : 2013-01-01
Age : 25
Location : USA
Re: SetScale command
did you test it?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);
}
}
}
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....
Re: SetScale command
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- Blocklandian
- Posts : 17
Join date : 2012-12-31
Age : 27
Location : Montreal
Re: SetScale command
Innocent wrote:There you go
- 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 but setPlayerScale was made for the events
Re: SetScale command
Just wanted to be precise so everybody understand ;)
Also, I just have the habit to use <color:Whatever>.. Made a topic about it :)
Also, I just have the habit to use <color:Whatever>.. Made a topic about it :)
Innocent- Blocklandian
- Posts : 17
Join date : 2012-12-31
Age : 27
Location : Montreal
Elite Square :: Blockland :: Coding Help
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|