Jump to content

[Help] Functions


iPollo

Recommended Posts

Hello everyone, I think I will still need to come here thousands of times to clear all doubts, so ...

I have this function declared on serverSide

function removeItemDoMundo(itemid)
    table.remove(spawnedItem_ID, itemid)
    table.remove(spawnedItem_NOME, itemid)
    table.remove(spawnedItem_X, itemid)
    table.remove(spawnedItem_Y, itemid)
    table.remove(spawnedItem_Z, itemid)
    table.remove(spawnedItem_ELEMENTO, itemid)
    removeWorldModel(spawnedItem_ID[itemid], 1.0, spawnedItem_X[itemid], spawnedItem_Y[itemid], spawnedItem_Z[itemid])
end

I'm trying to call it on the clientSide, but give this error: "attempt to call globally removeItemDoMundo a nil value"

Where I called, on clientSide:

function addItemAoInventario(itemid, objetoid, slot)
    table.insert(player_INV, slot, objetoid)
    removeItemDoMundo(itemid)
end

But the strange thing is that, debugging the itemid value, before the function is called, it shows "1" that exactly the value I need, but for some reason it says it is null, I don't know why

Link to comment
  • Scripting Moderators
5 minutes ago, iPollo said:

Hello everyone, I think I will still need to come here thousands of times to clear all doubts, so ...

I have this function declared on serverSide


function removeItemDoMundo(itemid)
    table.remove(spawnedItem_ID, itemid)
    table.remove(spawnedItem_NOME, itemid)
    table.remove(spawnedItem_X, itemid)
    table.remove(spawnedItem_Y, itemid)
    table.remove(spawnedItem_Z, itemid)
    table.remove(spawnedItem_ELEMENTO, itemid)
    removeWorldModel(spawnedItem_ID[itemid], 1.0, spawnedItem_X[itemid], spawnedItem_Y[itemid], spawnedItem_Z[itemid])
end

I'm trying to call it on the clientSide, but give this error: "attempt to call globally removeItemDoMundo a nil value"

Where I called, on clientSide:


function addItemAoInventario(itemid, objetoid, slot)
    table.insert(player_INV, slot, objetoid)
    removeItemDoMundo(itemid)
end

But the strange thing is that, debugging the itemid value, before the function is called, it shows "1" that exactly the value I need, but for some reason it says it is null, I don't know why

Server-side functions doesn't exist on client-side.

  • Thanks 1
Link to comment

Hello iPollo,

I remember that I helped you synchronize the serverside arrays with all clients using events. You remember those events, right? I think you have to be aware of a big problem if you want to remove items on the clientside: do all clients still have the same items defined? or does one client have more items than another?

For that reason I would recommend deleting the items on the server and resynchronizing the arrays using that event that we have discovered earlier this week. :) 

  • Thanks 1
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...