Author Topic: ripping the event_addItem to use in a function  (Read 3048 times)

Then add another argument to your function and use the extra argument.

Then add another argument to your function and use the extra argument.

how?


I need to get it to use a variable, though.

Further example
function serverCmdHaxer(%client,%argument) would make it so you can do /Haxer bleh and then %argument will be you variable and it will be "bleh"

Further example
function serverCmdHaxer(%client,%argument) would make it so you can do /Haxer bleh and then %argument will be you variable and it will be "bleh"

okay. so

Code: [Select]
function serverCmdAddSword(%client, %argument)
{
    if(isObject(%client.player))
    {
        %player = %client.player;
        %player.addItem(%argumentItem.getID(),%client);
    }
}

this is what u told me

That's not at all what I told you. I told you %argument not %argumentItem as those are two different variables.

That's not at all what I told you. I told you %argument not %argumentItem as those are two different variables.

it needs to have Item at the end of it.

tried to use

Code: [Select]
                   if(isObject(%client.player))
                    {
                        %weapondatanamei = %weapondataname @ Item;
                        %player = %client.player;
                        %player.addItem(%weapondatanamei.getID(),%client);
                    }

Add-Ons/Server_thing/server.cs (449): Unable to find object: 'Item' attempting to call function 'getid'

it needs to have Item at the end of it.
What makes you believe that? If that were the case and you use your function to do /addSword SwordItem as it seems to be intended then the SwordItem will be lost, because that makes %argument = SwordItem; when doing the command, and doesn't set %argumentItem to anything at all. If you wish to test this out for yourself you can do something like this:
function serverCmdItemTest(%client,%argument){messageClient(%client,'',%argument NL %argumentItem);}
Which is ready to be copied and pasted into your console. Then do /test Sword and you'll get the message:
Code: [Select]
Sword


Add-Ons/Server_thing/server.cs (449): Unable to find object: 'Item' attempting to call function 'getid'
That's because Item isn't an object, nor did you make it a variable. If you wish to tag a string to the end of that variable then you'd need to put it in quotes.

I'm completely lost and have no clue what you want to do

it needs to have Item at the end of it.
Variable names don't matter, as long as they match up. It could be called %peanutButterAndBananas as long as you define and reference it properly. . They're just there to tell you what the variable is used for


Add-Ons/Server_thing/server.cs (449): Unable to find object: 'Item' attempting to call function 'getid'
What value are you passing to the function for %argument?
Specifically what range of other values are you going to be passing to the function?

haha, sorry guys. the way I had it worked, I just forgeted up the variable because it wasn't defined in that function. it's all good now.

I'm completely lost and have no clue what you want to do

He's trying to add item to the end so he can do /addSword Sword instead of /addSword SwordItem and tried to do
%variable @ Item instead of %variable @ "Item"

He's trying to add item to the end so he can do /addSword Sword instead of /addSword SwordItem and tried to do
%variable @ Item instead of %variable @ "Item"

Yeah. Whoops.

tried to do
%variable @ Item instead of %variable @ "Item"

Ignoring case, these two are equivalent.
« Last Edit: January 08, 2015, 03:21:54 AM by portify »