Blockland Forums > Modification Help
Weapon Name
CityRPG:
--- Code: ---function serverCmdWhatchugot(%client, %name)
{
%target = findClientByName(%name);
if(!isObject(%target))
{
messageClient(%client, '', "Specified client does not exist.");
return;
}
%obj = %target.player;
if(!isObject(%obj))
{
messageClient(%client, '', "\c3" @ %target.name @ "\c0 has not spawned.");
return;
}
%tool = %obj.tool[%obj.currTool];
if(!isObject(%tool))
{
messageClient(%client, '', "\c3" @ %target.name @ "\c0 is not holding anything.");
return;
}
messageClient(%client, '', "\c3" @ %target.name @ "\c6 is wielding a \c3" @ %tool.uiName @ "\c6!");
}
--- End code ---
Ipquarx:
If you want a specific slot:
--- Code: ---%Client.player.tool[slot].uiName
--- End code ---
or replace tool[slot] with currtool to get the tool their holding.
Port:
Why do people always do this?:
--- Code: ---%obj = %target.player;
if ( !isObject( %obj ) )
{
// do stuff
}
--- End code ---
Why not just do this instead?:
--- Code: ---if ( !isObject( %obj = %target.player ) )
{
// do stuff
}
--- End code ---
CityRPG:
Because I'm not a neanderthal and I like my code to be legible.
Greek2me:
--- Quote from: Port on February 09, 2012, 02:09:53 AM ---Why do people always do this?:
--- End quote ---
Why does it matter? Also, what Kalphiter said.