Jump to content

[HELP] Script not work


1LoL1

Recommended Posts

  • Moderators

That has at the moment nothing to do with this. You are using addCommandHandler and not the company resource to trigger this function.

What? i want to with addCommandHandler send $ to company..

But i don't want to player i have firm system.

Then you should not have said that, because it has nothing to do with the problem.

And you know now how to solve it...

Link to comment

That has at the moment nothing to do with this. You are using addCommandHandler and not the company resource to trigger this function.

What? i want to with addCommandHandler send $ to company..

But i don't want to player i have firm system.

Then you should not have said that, because it has nothing to do with the problem.

And you know now how to solve it...

No i don't know.. i want only give player to element or i don't know what.. not player.

Link to comment
And why don't you show us the code then? Do you really think we can see through your eyes? -_-!

Here: work but i don't know how i can show how many $ is in in client-side (window)

mean:

local www = getElementData(test, "Data")

local label = guiCreateLabel(...)

guiSetText(www, ""..www.."")

money i know --> getPlayerMoney(localPlayer)

test = createElement("TEST") 
  
function w (source) 
local ddd = (getElementData(test, "Data") or 0) 
outputChatBox(""..ddd.."", source, 255, 255, 255, true) 
end 
addCommandHandler("data", w) 
  
function ww (source,command,amount) 
local money = getPlayerMoney(source) 
local amount = tonumber(math.floor(amount)) 
if (amount) then 
if tonumber(money) >= amount and amount > 0 then 
setElementData(test, "Data", (getElementData(test, "Data") or 0) + amount) 
takePlayerMoney(source, amount) 
outputChatBox("Player "..string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "").." --> "..convertNumber(amount).."$", getRootElement(), 255, 0, 0, true) 
else 
outputChatBox("test", source, 255, 0, 0, true) 
end 
end 
end 
addCommandHandler("ddr", ww) 
  

Link to comment
  • Moderators

1) You haven't added the fixes, this is still the same code as before.

2) Wtf is elementdata "data" ? Give it a good name.

local www = tonumber(getElementData(test, "Data")) or 0 
local label = guiCreateLabel(...) 

[strike]guiSetText(www, ""..www.."")[/strike] 

guiSetText(label,www) 

3) Wtf is www?

4) Where are your tabs?

Link to comment
1) You haven't added the fixes, this is still the same code as before.

2) Wtf is elementdata "data" ? Give it a good name.

local www = tonumber(getElementData(test, "Data")) or 0 
local label = guiCreateLabel(...) 

[strike]guiSetText(www, ""..www.."")[/strike] 

guiSetText(label,www) 

3) Wtf is www?

4) Where are your tabs?

All work normally.. but how i can show getElementData this data in window?

3) = look again..

guiSetText(label,www) and if i have there text? :o so guiSetText(label, "Money: "..www.."")

Link to comment
  • Moderators
All work normally.. but how i can show getElementData this data in window?

The same way as with the label. Using guiSetText.

3) = look again..

guiSetText(label,www) and if i have there text? :o so guiSetText(label, "Money: "..www.."")

I understand what a variable is, I only don't understand why you call it:www The name is just too hazy.

Link to comment
All work normally.. but how i can show getElementData this data in window?

The same way as with the label. Using guiSetText.

3) = look again..

guiSetText(label,www) and if i have there text? :o so guiSetText(label, "Money: "..www.."")

I understand what a variable is, I only don't understand why you call it:www The name is just too hazy.

Server-Side work normally.

and this too:

function Money (source) 
local money = (getElementData(test, "Data") or 0) 
outputChatBox("Money: "..convertNumber(money).."$!", source, 255, 255, 255, true) 
end 
addCommandHandler("money", Money) 

and here is Client-Side but not work..

function CreateShopWindow() 
    Window = guiCreateWindow(350,225,200,200,"TEST",false) 
    guiSetAlpha ( Window, 5.00 ) 
    guiWindowSetMovable ( Window, false ) 
   
  local money = (getElementData(test, "Data") or 0) 
  local C1 = guiCreateLabel(10,100,500,500,"",false,Window) 
  
  guiSetText (C1, "TEST: "..convertNumber(money).."$") 
   
  guiSetFont(C1, "default-bold-small") 
   
   
   
  guiWindowSetSizable(Window,false) 
end 
  
function convertNumber ( number )   
 local formatted = number   
 while true do       
  formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
  if ( k==0 ) then       
   break    
  end   
 end   
 return formatted 
end 
  
function ShowGUI ( ) 
CreateShopWindow () 
showCursor (true) 
local screenW,screenH = guiGetScreenSize() 
local windowW,windowH = guiGetSize(Window,false) 
local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
guiSetPosition(Window,x,y,false) 
end 
  
function window () 
  if isElement(Window) then 
    HideGUI() 
  else 
    ShowGUI() 
  end 
end 
bindKey ( "F5","down", window) 
  
function HideGUI () 
destroyElement (Window) 
showCursor(false) 
end 

Link to comment
This is what you must add: https://wiki.multitheftauto.com/wiki/OutputDebugString

Why would we look for an unknown mistake all the way down the code, while you can locate circa the location for us?

Wtf? i want only of SERVER-SIDE Money to show in Client-Side [WINDOW].....

Server-Side:

  
test = createElement("TEST") 
  
function Money (source) 
local money = (getElementData(test, "Data") or 0) 
outputChatBox("Money: "..convertNumber(money).."$!", source, 255, 255, 255, true) 
end 
addCommandHandler("money", Money) 

Client-Side:

function CreateShopWindow() 
    Window = guiCreateWindow(350,225,200,200,"TEST",false) 
    guiSetAlpha ( Window, 5.00 ) 
    guiWindowSetMovable ( Window, false ) 
  
  local money = (getElementData(test, "Data") or 0) 
  local C1 = guiCreateLabel(10,100,500,500,"",false,Window) 
  
  guiSetText (C1, "TEST: "..convertNumber(money).."$") 
  
  guiSetFont(C1, "default-bold-small") 
  
  
  
  guiWindowSetSizable(Window,false) 
end 
  
function convertNumber ( number )   
 local formatted = number   
 while true do       
  formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
  if ( k==0 ) then       
   break   
  end   
 end   
 return formatted 
end 
  
function ShowGUI ( ) 
CreateShopWindow () 
showCursor (true) 
local screenW,screenH = guiGetScreenSize() 
local windowW,windowH = guiGetSize(Window,false) 
local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
guiSetPosition(Window,x,y,false) 
end 
  
function window () 
  if isElement(Window) then 
    HideGUI() 
  else 
    ShowGUI() 
  end 
end 
bindKey ( "F5","down", window) 
  
function HideGUI () 
destroyElement (Window) 
showCursor(false) 
end 

Link to comment
Sorry, but you are very hard to help and only interested in the end product. I can't help you any further now, you should try to find somebody else who doesn't care about the debug process unlike me. Good luck!

Why hard?.. i said server-side work normally i want only client-side fix.

Link to comment
  • Moderators
Sorry, but you are very hard to help and only interested in the end product. I can't help you any further now, you should try to find somebody else who doesn't care about the debug process unlike me. Good luck!

Why hard?.. i said server-side work normally i want only client-side fix.

Because I am trying to teach you something so you can find your problem, but you are with your head somewhere else.

I can take a look at your code, spending 20 min looking for the mistake or I can let you debug it and you will learn something from it. And it will only cost 5 min of my time. The last methode is a standard of the scripting section, which is the one I prefer. It is a learning section after all.

Link to comment
Can you show your most recent code and re-state your exact problem?

server:

test = createElement("TEST") 
  
function Money (source) 
local money = (getElementData(test, "Data") or 0) 
outputChatBox("Money: "..convertNumber(money).."$!", source, 255, 255, 255, true) 
end 
addCommandHandler("money", Money) 

client:

function CreateShopWindow() 
    Window = guiCreateWindow(350,225,200,200,"TEST",false) 
    guiSetAlpha ( Window, 5.00 ) 
    guiWindowSetMovable ( Window, false ) 
  
  local money = (getElementData(test, "Data") or 0) 
  local C1 = guiCreateLabel(10,100,500,500,"",false,Window) 
  
  guiSetText (C1, "TEST: "..convertNumber(money).."$") 
  
  guiSetFont(C1, "default-bold-small") 
  
  
  
  guiWindowSetSizable(Window,false) 
end 
  
function convertNumber ( number )   
 local formatted = number   
 while true do       
  formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
  if ( k==0 ) then       
   break   
  end   
 end   
 return formatted 
end 
  
function ShowGUI ( ) 
CreateShopWindow () 
showCursor (true) 
local screenW,screenH = guiGetScreenSize() 
local windowW,windowH = guiGetSize(Window,false) 
local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
guiSetPosition(Window,x,y,false) 
end 
  
function window () 
  if isElement(Window) then 
    HideGUI() 
  else 
    ShowGUI() 
  end 
end 
bindKey ( "F5","down", window) 
  
function HideGUI () 
destroyElement (Window) 
showCursor(false) 
end 

And in server side works normally but how i can show money of server-side to client-side in label.

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