Jump to content

get()


#Paper

Recommended Posts

How i can use this function in clientside?

You can use the so:

Example:

  
local resourceName                  = getResourceName ( resource ) 
useGunsInSavePlace                  = get(resourceName..".UseGunsInSaveZone") 
  

meta

  
<setting name="#UseGunsInSaveZone"                    value="[ false ]" />   
  

and https://wiki.multitheftauto.com/wiki/Get

He asks if he could use this function CLIENT SIDE.

Link to comment

UNTESTED, but:

  
--client 
--'theSetting' is the name of the setting you want to retrieve (as a string) 
function clientGet(theSetting) 
    triggerServerEvent("onClientRequestSettings", getLocalPlayer(), theSetting) 
end 
--server 
function sendSettings(theSetting) 
     value = get(theSetting) 
     if value then  
        triggerClientEvent(source, "receiveSettings", source, value) 
     else 
        triggerClientEvent(source, "receiveSettings", source, false) 
end 
addEventHandler("onClientRequestSettings", getRootElement(), sendSettings) 
--the client requests the setting, then the server sends it back, but it needs a place to go. thats up to you. 
  

Link to comment
UNTESTED, but:
  
--client 
--'theSetting' is the name of the setting you want to retrieve (as a string) 
function clientGet(theSetting) 
    triggerServerEvent("onClientRequestSettings", getLocalPlayer(), theSetting) 
end 
--server 
function sendSettings(theSetting) 
     value = get(theSetting) 
     if value then  
        triggerClientEvent(source, "receiveSettings", source, value) 
     else 
        triggerClientEvent(source, "receiveSettings", source, false) 
end 
addEventHandler("onClientRequestSettings", getRootElement(), sendSettings) 
--the client requests the setting, then the server sends it back, but it needs a place to go. thats up to you. 
  

Thanks :D

I'm not in my pc, but when i am i'll test it ;D

Link to comment

I did adapt it for my needs, but it gives some errors:

asdhsg.jpg

-----SERVER SIDE 
addEvent("onClientRequestSettings", true) 
function sendSettings() 
local discoPrice = tonumber(clientGet("discoPrice")) 
local joinmsgPrice = tonumber(clientGet("joinmsgPrice")) 
local ghostPrice = tonumber(clientGet("ghostPrice")) 
local ghostDuration = tonumber(clientGet("ghostDuration")) * 1000 
local wavesPrice = tonumber(clientGet("wavesPrice")) 
local fixPrice = tonumber(clientGet("fixPrice")) 
local flipPrice = tonumber(clientGet("flipPrice")) 
local nitroPrice = tonumber(clientGet("nitroPrice")) 
triggerClientEvent(source, "receiveSettings", discoPrice, joinmsgPrice, ghostPrice, ghostDuration, wavesPrice, fixPrice, flipPrice, nitroPrice) 
end 
addEventHandler("onClientRequestSettings", getRootElement(), sendSettings) 
-----CLIENT SIDE 
function clientGet() 
    triggerServerEvent("onClientRequestSettings", getLocalPlayer()) 
end 
  
addEvent("receiveSettings", true) 
function setsValues(disco, join, ghostP, ghostDur, wave, fix, flip, nitro) 
local discoPrice = disco 
local joinmsgPrice = join 
local ghostPrice = ghostP 
local ghostDuration = ghostDur 
local wavesPrice = wave 
local fixPrice = fix 
local flipPrice = flip 
local nitroPrice = nitro 
end 
addEventHandler("receiveSettings", getRootElement(), sendSettings) 

Link to comment
How i can use this function in clientside?

You can use the so:

Example:

  
local resourceName                  = getResourceName ( resource ) 
useGunsInSavePlace                  = get(resourceName..".UseGunsInSaveZone") 
  

meta

  
<setting name="#UseGunsInSaveZone"                    value="[ false ]" />   
  

and https://wiki.multitheftauto.com/wiki/Get

He asks if he could use this function CLIENT SIDE.

I have not noticed that he was referring to the client side :D

Link to comment
Dude, what's the point of asking for a function that is only server-side to work on client-side and then use it on server-side?, you are using 'clientGet' on server side part.

I need to get the settings from the resource in client side... then i use the clientGet func in CS...

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...