Jump to content

Help me buy gui


Recommended Posts

Posted (edited)

Hello :D

I learned a bit GUI , but i added to GMS script Buy window and i deletd the another.It didnt works . I started it and when i go to server nothing happeneds . Can you help me ? pls . Here is my code:

function guiToggleVisible ( )
 
if ( guiGetVisible ( myWindow ) == true ) then           
guiSetVisible ( myWindow, false )
showCursor ( false )
else      
guiSetVisible ( myWindow, true )
showCursor ( true )
end
end
 
myWindow = guiCreateWindow ( 0, 0, .10, .10, "Buy window", true )
local tabPanel = guiCreateTabPanel ( 0, 10.0, 6, 2, true, myWindow )
local tabCommands = guiCreateTab( "Buy", tabPanel )
 
Buynitro_button = guiCreateButton( 0.1, 0.1, 0.50, 0.10, "Buy nitro", true, tabCommands )
Buyrepair_button = guiCreateButton( 0.1, 0.2, 0.50, 0.10, "Buy repair", true, tabCommands )
exit1_button = guiCreateButton( 0.30, 0.85, 0.5, 0.03, "Close Panel (F4)", true, tabCommands )
 
bindKey ( "u", "down", guiToggleVisible )
 
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
function ( )
if (source == exit1_button) then
guiSetVisible( myWindow, false )
showCursor( false )
end  
end
)
 
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
function ( )
if (source == buynitro_button) then
getPlayerMoney(player) > 100 then
local vehicle = getPedOccupiedVehicle(player)
if vehicle then 
addVehicleUpgrade(vehicle, 1010)
takePlayerMoney(player, 100)
outputChatBox("You've bought a nitro", player, 0, 222, 0, true)
else 
outputChatBox("You are not in a vehicle", player, 222, 0, 0, true) 
end
else 
outputChatBox("Not enough cash, nitro costs 100", player, 222, 0, 0, true) 
end
 
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
function ( )
if (source == Buyrepair_button) then
if getPlayerMoney(player) > 100 then
local vehicle = getPedOccupiedVehicle(player)
if vehicle then 
fixVehicle(vehicle) 
takePlayerMoney(player, 100)
outputChatBox("You've bought a repair", player, 0, 222, 0, true)
else 
outputChatBox("You are not in a vehicle", player, 222, 0, 0, true) 
end
else 
outputChatBox("Not enough cash, repair costs 100 ", player, 222, 0, 0, true) 
end
end
end 
)

Can anyone help me pls ?

Edited by Guest
Posted

you have mixed server-side with client-side scripts..

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

Client side outputChatBox = outputChatBox (message, r, g, b)

so no need to have outputChatBox (message, player, r, g, b)

also if calling a player required function, try using getLocalPlayer() or before the script add: player = getLocalPlayer()

Posted (edited)

Well i nned to add local player = getLocallayer() ? k ty for helping but i need to test

dont works... and i dont know making server side

Edited by Guest
Posted
:shock::shock::shock::shock::shock::shock::shock: man.. why dont u make a whole new one cuz gms script is way diferent then what u want
I said i maked it with GMS scrit i deleted the another and i added the buy so Can you help me?
Posted (edited)

I maked it with Gui editor

i think i worked on it 3 or 4 hours , but it didnt works -.-'

Can anyone help me ?

When i type debugscript 3 it gives:

[16:17:33] Starting resources...............
[16:17:34] Server started and is ready to accept connections!
[16:17:36] start: Requested by Console
[16:17:36] Starting buy
[16:17:36] SCRIPT ERROR: ...iles/MTA San Andreas/server/mods/deathmatch/resources/buy/Untitled 1.lua:13: unexpected symbol near '>'
[16:17:36] WARNING: Loading script failed: ...iles/MTA San Andreas/server/mods/deathmatch/resources/buy/Untitled 1.lua:13: unexpected symbol near '>'
[16:17:36] start: Resource 'buy' started
[16:18:10] debugscript: Incorrect client type for this command

Here is my code :

GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}
 
GUIEditor_Window[1] = guiCreateWindow(161,102,390,342,"Buy window",false)
GUIEditor_Button[1] = guiCreateButton(31,25,90,18,"Buy nitro",false,GUIEditor_Window[1])
GUIEditor_Button[2] = guiCreateButton(30,46,91,17,"Buy repair",false,GUIEditor_Window[1])
GUIEditor_Memo[1] = guiCreateMemo(131,25,209,50,"Press Buy nitro to buy a niro\nPress buy repair to buy a repair",false,GUIEditor_Window[1])
 
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
function ( )
if (source == GUIEditor_Button[1]) then
getPlayerMoney(player) > 100 then
local vehicle = getPedOccupiedVehicle(player)
local player = getLocalPlayer()
if vehicle then 
addVehicleUpgrade(vehicle, 1010)
takePlayerMoney(player, 100)
outputChatBox("You've bought a nitro", player, 0, 222, 0, true)
else 
outputChatBox("You are not in a vehicle", player, 222, 0, 0, true) 
end
else 
outputChatBox("Not enough cash, nitro costs $100", player, 222, 0, 0, true) 
end
 
 
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
function ( )
if (source == GUIEditor_Button[2]) then
if getPlayerMoney(player) > 100 then
local vehicle = getPedOccupiedVehicle(player)
local player = getLocalPlayer()
if vehicle then 
fixVehicle(vehicle) 
takePlayerMoney(player, 100)
outputChatBox("You've bought a repair", player, 0, 222, 0, true)
else 
outputChatBox("You are not in a vehicle", player, 222, 0, 0, true) 
end
else 
outputChatBox("Not enough cash, repair costs 100 ", player, 222, 0, 0, true) 
end
end
end 
)

Edited by Guest
Posted

lol listen to people xD

someone said outputchatbox is wrong well.... we see u didnt look at it :wink:

btw

my offer stands for 1 more hour not more not less

Posted
Can anyone help me ? pls :fadein:

not if you're ignoring... please use outPutChatbox in server side

and make a normal gui + variables (names) :|

if u made that im willing to make you a server side

Posted

I used outputChatBox lol

Client side outputChatBox = outputChatBox (message, r, g, b)

so no need to have outputChatBox (message, player, r, g, b)

also if calling a player required function, try using getLocalPlayer() or before the script add: player = getLocalPlayer()

I used that in red ,it should to be outputChatBox = outputChatBox (message, r, g, b) ? °-°

And i added :

player = getLocalPlayer()

Posted

There's no point in

Do NOT PM ME for help unless invited. - New MTA Script Editor

Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.

Posted

posting tons and tons of posts directly after another...

Do NOT PM ME for help unless invited. - New MTA Script Editor

Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.

Posted

well, i made it for you but you must know that i wont make anything u post here so start to learn by yourself :)

client side:

GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}
 
GUIEditor_Window[1] = guiCreateWindow(161,102,390,342,"Buy window",false)
GUIEditor_Button[1] = guiCreateButton(31,25,90,18,"Buy nitro",false,GUIEditor_Window[1])
GUIEditor_Button[2] = guiCreateButton(30,46,91,17,"Buy repair",false,GUIEditor_Window[1])
GUIEditor_Memo[1] = guiCreateMemo(131,25,209,50,"Press Buy nitro to buy a niro\nPress buy repair to buy a repair",false,GUIEditor_Window[1])
guiSetVisible(GUIEditor_Window[1], false)
 
function guiToggleVisible ( )
 
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 ( "M", "down", guiToggleVisible )
 
function fixv()
triggerServerEvent("fixRequest", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[2],fixv,false)
 
function nitro()
triggerServerEvent("nitro", getLocalPlayer())
end
addEventHandler("onClientGUIClick",GUIEditor_Button[1],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
)

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Thank you very much. :D

no problem, and remember to start to learn!!!

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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