Jump to content

[help]A little problem on testing


Xierra

Recommended Posts

Hi guys

I have a problem.

When I create an xpeffects function (addXpEffect), and I want to make it work on another resource.

It's a client-side script. But how can I do it? Should I export functions? If yes, How?

Because I got an error "ERROR:.../deathmatch/resources/test/aaa.lua:2:Trying to call global "addXpEffect" (a nil value)"

The script (aaa.lua):

function xpea()
string = addXpEffect("AA", "+1000", {r=100, g=0, b=0}) --the xpeffects function.
 
if (string) then
outputChatBox("It's working!")
else
outputChatBox("no it's not working")
end
end
addCommandHandler ( "xp", xpea)

Meta.xml:

<meta>
<script src="aaa.lua" />
meta>

Can you guys learn me the easy way of exporting functions from another resource?

Link to comment

First of all please try indenting your code ;) That improves the readability pretty much.

Anyway I guess you rather want to call an exported function than exporting a function yourself so in this case you need to make use of the call function which allows you to call exported functions of other resources.

Assuming that you're trying to use my xpeffects resource you also need to correct some other mistakes:

First of all it's addXPEffects with both X and P being capital letters, secondly the function doesn't return anything so the "string" variable will always be nil and last the color argument needs to be a table in this form {r, g, b}.

So in the end your code should look something like this:

function xpea ()
   exports.xpeffects:addXPEffect ( "AA", "+1000", {100, 0, 0} )
end
 
addCommandHandler ( "xp", xpea )

Link to comment

Before I end this topic, the syntax ( player, title, description, color )

In cs_sounds, It doesn't have "player" inside the function, but the script have argument "killer"

Will it ok if I write something like: (killer, "AA", "+1000", {200,200,200})

I'm not sure yet because Nobody is gonna test it for me. :)

A little tip: I am trying to make use of xpeffects script, that's why I edit cs_sounds script.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...