Jump to content

Stats gui dont works , pls help me


loler

Recommended Posts

Hey all.

I maked a stats gui but it didnt works

when i type in console

start stats

it gives:

[11:52:56] Starting Stats
[11:52:56] SCRIPT ERROR: ...am Files/MTA San Andreas/server/mods/deathmatch/resources/Stats/shop.lua:31: ')' expected near 'playerMoney'
[11:52:56] WARNING: Loading script failed: ...am Files/MTA San Andreas/server/mods/deathmatch/resources/Stats/shop.lua:31: ')' expected near 'playerMoney'
[11:52:56] start: Resource 'stats' started

Ok here is my code:

function OpenStatusWindow()
 
guiSetVisible( GUIEditor_Window[1], not guiGetVisible( GUIEditor_Window[1] ) )
showCursor( guiGetVisible( GUIEditor_Window[1] ) )
 
end
 
addCommandHandler("userpanel",OpenStatusWindow)
 
 
function createGUI()
 
bindKey("F5","down",OpenStatusWindow)
 
 
GUIEditor_Window = {}
GUIEditor_Label = {}
GUIEditor_Image = {}
-- Get data
local playerMoney = getElementData(getLocalPlayer(), "Money")	
local playerPoints = getElementData(getLocalPlayer(), "Points")
local playerWins = getElementData(getLocalPlayer(), "Wins")	
local playerLoses = getElementData(getLocalPlayer(), "Loses")
 
 
GUIEditor_Window[1] = guiCreateWindow(229,191,508,515,"Stats gui by loler",false)
GUIEditor_Label[1] = guiCreateLabel(12,18,5,5,"",false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[1],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false)
GUIEditor_Label[2] = guiCreateLabel(30,28,161,24,"Player money:"playerMoney,false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[2],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false)
GUIEditor_Label[3] = guiCreateLabel(30,47,179,16,"Player points:"..playerPoints,false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)
GUIEditor_Label[4] = guiCreateLabel(30,64,152,16,"Player wins:" ..playerWins,false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[4],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"left",false)
GUIEditor_Label[5] = guiCreateLabel(29,83,163,19,"Player loses:"..playerLoses,false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[5],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[5],"left",false)
GUIEditor_Label[6] = guiCreateLabel(23,490,441,16,"Stats gui made by loler.May be not released without his permision.Have fun!!",false,GUIEditor_Window[1])
guiLabelSetColor(GUIEditor_Label[6],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[6],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[6],"left",false)
GUIEditor_Image[1] = guiCreateStaticImage(227,53,272,375,"images/mtalogo.png",false,GUIEditor_Window[1])
 
 
 
-- Hide userpanel when Recource starts	
guiSetVisible( GUIEditor_Window[1], false)	
 
 
 
end
addEventHandler("onClientResourceStart",resourceRoot,createGUI)

Can anyone help me ? please :|

Link to comment

2 years of MTA scripting experience? REALLY?

Your mistakes are simple and stupid and seems like you just copy your script here when it doesn't work. Did you at least read the line which produces error?

GUIEditor_Label[2] = guiCreateLabel(30,28,161,24,"Player money:"playerMoney,false,GUIEditor_Window[1])

You're missing ..

GUIEditor_Label[2] = guiCreateLabel(30,28,161,24,"Player money:"..playerMoney,false,GUIEditor_Window[1])

Link to comment

Ok i maked one more , pls dont say that i sthealed cuz i didnt ( speccialy for the_ex)

i stayed 3 hours on it -.-'

Client side:

addCommandHandler("userpanel",OpenStatusWindow)
 
 
function createGUI()
 
bindKey("F5","down",OpenStatusWindow)
 
GUIEditor_Window = {}
GUIEditor_TabPanel = {}
GUIEditor_Tab = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}
GUIEditor_Label = {}
 
local player = getPlayerName(getLocalPlayer())
local playerMoney = getElementData(getLocalPlayer(), "Money")	
local playerPoints = getElementData(getLocalPlayer(), "Points")
local playerWins = getElementData(getLocalPlayer(), "Wins")	
local playerLoses = getElementData(getLocalPlayer(), "Loses")
 
 
GUIEditor_Window[1] = guiCreateWindow(11,135,275,194,"User panel",false)
GUIEditor_TabPanel[1] = guiCreateTabPanel(12,23,249,162,false,GUIEditor_Window[1])
GUIEditor_Tab[1] = guiCreateTab("User",GUIEditor_TabPanel[1])
GUIEditor_Label[1] = guiCreateLabel(10,11,222,19,"Name: " .. player,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[1],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false)
GUIEditor_Label[2] = guiCreateLabel(10,32,222,19,"Money: $" .. playerMoney,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[2],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false)		
GUIEditor_Label[3] = guiCreateLabel(10,52,222,19,"Points: " .. playerPoints,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)	
GUIEditor_Label[4] = guiCreateLabel(10,52,222,19,"Wins: " .. playerWins,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)		
GUIEditor_Label[5] = guiCreateLabel(10,52,222,19,"Loses: " .. playerLoses,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)	
GUIEditor_Tab[2] = guiCreateTab("Shop",GUIEditor_TabPanel[1])	
GUIEditor_Label[6] = guiCreateLabel(18,14,142,16,"Repair:",false,GUIEditor_Tab[2])
guiLabelSetColor(GUIEditor_Label[4],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"left",false)	
GUIEditor_Label[7] = guiCreateLabel(18,33,142,16,"Nitro:",false,GUIEditor_Tab[2])
guiLabelSetColor(GUIEditor_Label[5],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[5],"left",false)		
GUIEditor_Label[8] = guiCreateLabel(18,53,142,16,"Barrel:",false,GUIEditor_Tab[2])
guiLabelSetColor(GUIEditor_Label[6],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[6],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[6],"left",false)		
GUIEditor_Label[9] = guiCreateLabel(18,73,142,16,"Haystack:",false,GUIEditor_Tab[2])
guiLabelSetColor(GUIEditor_Label[7],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[7],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[7],"left",false)	
GUIEditor_Button[1] = guiCreateButton(67,14,46,17,"$3500",false,GUIEditor_Tab[2])
GUIEditor_Button[2] = guiCreateButton(62,34,46,17,"$2000",false,GUIEditor_Tab[2])
GUIEditor_Button[3] = guiCreateButton(50,54,46,17,"$1500",false,GUIEditor_Tab[2])
GUIEditor_Button[4] = guiCreateButton(88,74,46,17,"$3000",false,GUIEditor_Tab[2])
GUIEditor_Button[5] = guiCreateButton(92,94,46,17,"$4000",false,GUIEditor_Tab[2])
function fixv()
triggerServerEvent("fixRequest", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[1],fixv,false)
function nitro()
triggerServerEvent"nitro", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[2],nitro,false)
function barrel()
triggerServerEvent("barrel", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[3],barrel,false)
triggerServerEvent("haystack", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[4],haystack,false)
 
GUIEditor_Tab[3] = guiCreateTab("Credits",GUIEditor_TabPanel[1])
GUIEditor_Memo[1] = guiCreateMemo(7,6,233,127,"User panel by loler",false,GUIEditor_Tab[3])
guiMemoSetReadOnly(GUIEditor_Memo[1],true)
GUIEditor_Tab[4] = guiCreateTab("Top Points",GUIEditor_TabPanel[1])
GUIEditor_Label[9] = guiCreateLabel(9,11,223,21,"Coming soon \"{SMILIES_PATH}/icon_wink.gif\" alt=\"\" title=\"Wink\" />",false,GUIEditor_Tab[4])
guiLabelSetColor(GUIEditor_Label[9],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[9],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[9],"left",false)
 
-- Hide userpanel when Recource starts	
guiSetVisible( GUIEditor_Window[1], false)	
 
 
 
end
addEventHandler("onClientResourceStart",resourceRoot,createGUI)

Server side:

addEvent("nitro", true)
addEventHandler("nitro", getRootElement(),
function()
if isPedInVehicle(source) then
if ( getPlayerMoney (source) >= 7000 ) then
takePlayerMoney(source, 7000)
addVehicleUpgrade(getPedOccupiedVehicle(source),1010)
outputChatBox("Nitro Successfully added", source, 255, 255, 0, true)
else
outputChatBox("Not enough money.", source, 255, 0, 0, true)
end 
else
outputChatBox("You are not in a vehicle", source, 255, 0, 0, true)
end
end
)
addEvent("fixRequest", true)
addEventHandler("fixRequest", getRootElement(),
function()
if isPedInVehicle(source) then
if ( getPlayerMoney (source) >= 20000 ) then
takePlayerMoney(source, 20000)
fixVehicle(getPedOccupiedVehicle(source))
outputChatBox("Vehicle Successfully Fixed", source, 255, 255, 0, true)
else
outputChatBox("Not enough money.", source, 255, 0, 0, true)
end 
else
outputChatBox("You are not in a vehicle", source, 255, 0, 0, true)
end
end
)
addEvent("haystack", true)
addEventHandler("haystack", getRootElement(),
function()
local x,y,z = getElementPosition( player )
if isPedInVehicle(source) then
if ( getPlayerMoney (source) >= 99999 ) then
takePlayerMoney(source, 99999)
createObject ( 3374 , x , y , z )
outputChatBox("Haystack Successfully planted", source, 255, 255, 0, true)
else
outputChatBox("Not enough money.", source, 255, 0, 0, true)
end 
else
outputChatBox("You are not in a vehicle", source, 255, 0, 0, true)
end
end
)
addEvent("barrel", true) 
addEventHandler("barrel", getRootElement(),
function()
local x,y,z = getElementPosition( player )
if isPedInVehicle(source) then
if ( getPlayerMoney (source) >= 100000 ) then
takePlayerMoney(source, 100000)
createObject ( 1225 , x , y , z )
outputChatBox("Barrel Successfully planted", source, 255, 255, 0, true)
else
outputChatBox("Not enough money.", source, 255, 0, 0, true)
end 
else
outputChatBox("You are not in a vehicle", source, 255, 0, 0, true)
end
end
)

Edited by Guest
Link to comment
Nah , check ALL the mta scripting subforum and you will see :wink:

im sorry but u copyed it from my code at least server side parts ;)

https://forum.multitheftauto.com/viewtopic.php?f=91&t=27814&st=0&sk=t&sd=a&start=15

but well, i fixed all code for you.

client side:

GUIEditor_Window = {}
GUIEditor_TabPanel = {}
GUIEditor_Tab = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}
GUIEditor_Label = {}
 
function toggleVisible ( )
if ( guiGetVisible ( GUIEditor_Window[1] ) == true ) then           
guiSetVisible ( GUIEditor_Window[1], false )
showCursor ( false )
else 
guiSetVisible ( GUIEditor_Window[1], true )
showCursor ( true )
end
end
bindKey ( "F6", "down", toggleVisible )
 
local player = getPlayerName(getLocalPlayer())
local playerMoney = getPlayerMoney(source)
local playerPoints = getElementData(getLocalPlayer(), "Points")
local playerWins = getElementData(getLocalPlayer(), "Wins")   
local playerLoses = getElementData(getLocalPlayer(), "Loses")
 
GUIEditor_Window[1] = guiCreateWindow(11,135,275,194,"User panel",false)
guiSetVisible( GUIEditor_Window[1], false)   
  GUIEditor_TabPanel[1] = guiCreateTabPanel(12,23,249,162,false,GUIEditor_Window[1])
  GUIEditor_Tab[1] = guiCreateTab("User",GUIEditor_TabPanel[1])
  GUIEditor_Label[1] = guiCreateLabel(10,11,222,19,"Name: " .. player,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[1],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false)
  GUIEditor_Label[2] = guiCreateLabel(10,32,222,19,"Money: $ " ..playerMoney,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[2],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false)      
  GUIEditor_Label[3] = guiCreateLabel(10,52,222,19,"Points: " .. playerPoints,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)   
  GUIEditor_Label[4] = guiCreateLabel(10,52,222,19,"Wins: " .. playerWins,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)      
  GUIEditor_Label[5] = guiCreateLabel(10,52,222,19,"Loses: " .. playerLoses,false,GUIEditor_Tab[1])
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)   
  GUIEditor_Tab[2] = guiCreateTab("Shop",GUIEditor_TabPanel[1])   
  GUIEditor_Label[6] = guiCreateLabel(18,14,142,16,"Repair:",false,GUIEditor_Tab[2])
guiLabelSetColor(GUIEditor_Label[4],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"left",false)   
  GUIEditor_Label[7] = guiCreateLabel(18,33,142,16,"Nitro:",false,GUIEditor_Tab[2])
guiLabelSetColor(GUIEditor_Label[5],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[5],"left",false)      
  GUIEditor_Label[8] = guiCreateLabel(18,53,142,16,"Barrel:",false,GUIEditor_Tab[2])
guiLabelSetColor(GUIEditor_Label[6],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[6],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[6],"left",false)      
  GUIEditor_Label[9] = guiCreateLabel(18,73,142,16,"Haystack:",false,GUIEditor_Tab[2])
guiLabelSetColor(GUIEditor_Label[7],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[7],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[7],"left",false)   
  GUIEditor_Button[1] = guiCreateButton(67,14,46,17,"$3500",false,GUIEditor_Tab[2])
  GUIEditor_Button[2] = guiCreateButton(62,34,46,17,"$2000",false,GUIEditor_Tab[2])
  GUIEditor_Button[3] = guiCreateButton(50,54,46,17,"$1500",false,GUIEditor_Tab[2])
  GUIEditor_Button[4] = guiCreateButton(88,74,46,17,"$3000",false,GUIEditor_Tab[2])
  GUIEditor_Button[5] = guiCreateButton(92,94,46,17,"$4000",false,GUIEditor_Tab[2])
  GUIEditor_Tab[3] = guiCreateTab("Credits",GUIEditor_TabPanel[1])
  GUIEditor_Memo[1] = guiCreateMemo(7,6,233,127,"User panel by loler",false,GUIEditor_Tab[3])
guiMemoSetReadOnly(GUIEditor_Memo[1],true)
  GUIEditor_Tab[4] = guiCreateTab("Top Points",GUIEditor_TabPanel[1])
  GUIEditor_Label[9] = guiCreateLabel(9,11,223,21,"Coming soon",false,GUIEditor_Tab[4])
guiLabelSetColor(GUIEditor_Label[9],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[9],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[9],"left",false)
 
function fixv()
triggerServerEvent("fixRequest", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[1],fixv,false)
 
function haystack()
triggerServerEvent("haystack", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[4],haystack,false)
 
function barrel()
triggerServerEvent("barrel", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[3],barrel,false)
 
function nitro()
triggerServerEvent("nitro", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[2],nitro,false)

server side:

addEvent("nitro", true)
addEventHandler("nitro", getRootElement(),
function()
if isPedInVehicle(source) then
if ( getPlayerMoney (source) >= 7000 ) then
takePlayerMoney(source, 7000)
addVehicleUpgrade(getPedOccupiedVehicle(source),1010)
outputChatBox("Nitro Successfully added", source, 255, 255, 0, true)
else
outputChatBox("Not enough money.", source, 255, 0, 0, true)
end
else
outputChatBox("You are not in a vehicle", source, 255, 0, 0, true)
end
end
)
addEvent("fixRequest", true)
addEventHandler("fixRequest", getRootElement(),
function()
if isPedInVehicle(source) then
if ( getPlayerMoney (source) >= 20000 ) then
takePlayerMoney(source, 20000)
fixVehicle(getPedOccupiedVehicle(source))
outputChatBox("Vehicle Successfully Fixed", source, 255, 255, 0, true)
else
outputChatBox("Not enough money.", source, 255, 0, 0, true)
end
else
outputChatBox("You are not in a vehicle", source, 255, 0, 0, true)
end
end
)
addEvent("haystack", true)
addEventHandler("haystack", getRootElement(),
function()
local x,y,z = getElementPosition( source )
if isPedInVehicle(source) then
if ( getPlayerMoney (source) >= 99999 ) then
takePlayerMoney(source, 99999)
createObject ( 3374 , x , y , z )
outputChatBox("Haystack Successfully planted", source, 255, 255, 0, true)
else
outputChatBox("Not enough money.", source, 255, 0, 0, true)
end
else
outputChatBox("You are not in a vehicle", source, 255, 0, 0, true)
end
end
)
addEvent("barrel", true)
addEventHandler("barrel", getRootElement(),
function()
local x,y,z = getElementPosition( source )
if isPedInVehicle(source) then
if ( getPlayerMoney (source) >= 100000 ) then
takePlayerMoney(source, 100000)
createObject ( 1225 , x , y , z )
outputChatBox("Barrel Successfully planted", source, 255, 255, 0, true)
else
outputChatBox("Not enough money.", source, 255, 0, 0, true)
end
else
outputChatBox("You are not in a vehicle", source, 255, 0, 0, true)
end
end
)

greetings, Castillo

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