Author Topic: Stuck on scripting  (Read 3453 times)

Destiny's addItem function:
Code: [Select]
function Player::addItem(%player,%image,%client)
{
   for(%i = 0; %i < %player.getDatablock().maxTools; %i++)
   {
      %tool = %player.tool[%i];
      if(%tool == 0)
      {
         %player.tool[%i] = %image;
         %player.weaponCount++;
         messageClient(%client,'MsgItemPickup','',%i,%image);
         break;
      }
   }
}
So how to I make that image the sword image?

%image
Probably means it's looking for an item's image.
wrenchImage
hammerImage

Here's some example code with some revised code:
(the old one was styled for an event)
Code: [Select]
function Player::addItem(%this,%image)
{
   for(%i = 0; %i < %this.getDatablock().maxTools; %i++)
   {
      %tool = %this.tool[%i];
      if(%tool == 0)
      {
         %this.tool[%i] = %image;
         %this.weaponCount++;
         messageClient(%this.client,'MsgItemPickup','',%i,%image);
         break;
      }
   }
}

findclientbyname(heed).player.addItem(wrenchImage);

It doesn't add the item. It makes the sound of the item being added but a blank ? shows up instead of a wrench

It doesn't add the item. It makes the sound of the item being added but a blank ? shows up instead of a wrench

You need to add wrenchItem, not wrenchImage.

You need to add wrenchItem, not wrenchImage.
Sorry, mounting directly (mountImage) uses an image, I wonder why Destiny named it %image.

Sorry, mounting directly (mountImage) uses an image, I wonder why Destiny named it %image.

Variable names don't matter. Plus, it calls MsgItemPickup.

Variable names don't matter. Plus, it calls MsgItemPickup.
I never said they do

Anyone could do this:
Code: [Select]
function servercmddie(%chicken)
{
    if(isObject(%chicken.player))
        %chicken.player.kill();
}
But do they? No.

Anyone could do this:
Code: [Select]
function servercmddie(%chicken)
{
    if(isObject(%chicken.player))
        %chicken.player.kill();
}
But do they? No.
They don't do it, because someday they'll make an update/change the script and they don't understand what it means
(I assume they aren't good scripters, because only people who are new to scripting make a die servercommand)

(I assume they aren't good scripters, because only people who are new to scripting make a die servercommand)
Like me D:

Code: [Select]
Function ServercmdKill(%client, %name)
{
If(!%client.isadmin)
{
messageclient(%client, "", "\c3This is an admin only command.");
return;
}
%victim = findclientbyname(%target);
if(!%victim) %victim = findclientbyBL_ID(%target)
if(!%victim)
{
messageclient(%client, "", "No player was found.");
return;
}
if(isObject(%victim.player)) %victim.player.kill();
else messageclient(%client, "", "\c3That player is not alive.");
}


Syntax errors. Line one. Around the %client area.

Don't capitalize 'function'.


Don't capitalize 'function'.
Didn't think it was case sensitive.

Fixed that part, now syntax errors around the second
Code: [Select]
if(!%victim)

Code: [Select]
if(!%victim) %victim = findclientbyBL_ID(%target)
if(!%victim)
{
messageclient(%client, "", "No player was found.");
return;
}

Why not make those one statement?

Code: [Select]
if(!%victim) %victim = findclientbyBL_ID(%target)
if(!%victim)
{
messageclient(%client, "", "No player was found.");
return;
}

Why not make those one statement?
How?