Jump to content

sheenidgs

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by sheenidgs

  1. CLIENT triggerServerEvent ( "kick", resourceRoot, abc ) SERVER function fox ( player ) kickPlayer( player ) end In abc, make sure that's a player who you want to kick OR you can do this solution CLIENT triggerServerEvent ( "kick", targetPlayer ) SERVER function fox () kickPlayer( source ) end targetPlayer = the player that you want kick
  2. Make sure your Apache and MySQL is running. Open your XAMPP Control Panel
  3. Try this CLIENT SCRIPT function bind_c() -- get the veh first local veh = getPedOccupiedVehicle( localPlayer ) if veh then -- if the veh is valid -- you need an argument IF the handled function has some arguments triggerServerEvent ( "create", resourceRoot, veh ) end end SERVER-SIDE weapOff = {} weapOff[422] = {-0.1, -1.9, -0.2, 0, 30, 60} weapOff[470] = {-0.1, 0.1, 1.0, 0, 30, 60} function createVehicleMachinegun (veh) local x,y,z = getElementPosition(veh) local mid = getElementModel(veh) if weapOff[mid] then local weapon = createObject ( 362, x+weapOff[mid][1],y+weapOff[mid][2],z+weapOff[mid][3]) local weapon_base = createObject ( 336, x+weapOff[mid][1],y+weapOff[mid][2],z) attachElements ( weapon_base, veh, weapOff[mid][1], weapOff[mid][2], weapOff[mid][3], 0, 0, 0) attachElements ( weapon, weapon_base, 0, -0.3, 0.9, weapOff[mid][4], weapOff[mid][5], weapOff[mid][6]) setElementData(veh, "weapon", weapon_base) setElementData(veh, "weapon2", weapon) setElementData(veh, "playerOnWeapon", nil) outputChatBox ( "Machinegun attached!" ) end end addEvent( "create", true ) addEventHandler( "create", root, createVehicleMachinegun )
  4. Thanks for your inspiration!!!! I've solve this problem with this way: - create a resource with Meta.xml file only for resource info Meta.xml from resource mysql "Rachmad Setiawan" type="configuration" name="MySQL" version="1.0" description="A MySQL Configuration from A Resource" /> - include this resource (mysql) to a target resource (the resource that you want to use this configuration) Meta.xml "Rachmad Setiawan" type="client-login" name="Login Panel" version="1.0" description="A login panel using MySQL" /> -- Butuh resource lain untuk konfigurasinya, seperti MySQL --> resource="mysql" /> - add resource owner (mysql) to the configuration -- Pengaturan koneksi ke database di MySQL --> "#mysql.host" value="127.0.0.1"> "#mysql.port" value="3306"> "#mysql.user" value="mta-sa"> "#mysql.pass" value="mta"> "#mysql.db" value="mta_sa"> - get the configuration server.lua local sqlHandle = nil local connString = nil local accParse = { "id","admin","level","team","xp","points","skin","kills","deaths","location","money","bank" } -- inisialisasi MySQL local sqlHost = "host=" ..get( "mysql.host" ) or "none" local sqlPort = "port=" ..get( "mysql.port" ) or "none" local sqlUser = get( "mysql.user" ) or "none" local sqlPass = get( "mysql.pass" ) or "none" local sqlDB = "dbname=" ..get( "mysql.db" ) or "none" Thanks for the help
  5. Hi I want ask my problem about settings.xml I have a script like this server.lua local sqlHandle = nil local connString = nil local accParse = { "id","admin","level","team","xp","points","skin","kills","deaths","location","money","bank" } -- inisialisasi MySQL local sqlHost = "host=" ..get( "MySQLHost" ) or "none" local sqlPort = "port=" ..get( "MySQLPort" ) or "none" local sqlUser = get( "MySQLUser" ) or "none" local sqlPass = get( "MySQLPass" ) or "none" local sqlDB = "dbname=" ..get( "MySQLDB" ) or "none" settings.xml "MySQLHost" value="127.0.0.1"> "MySQLPort" value="3306"> "MySQLUser" value="mta-sa"> "MySQLPass" value="mta"> "MySQLDB" value="mta_sa"> In server.lua, I use get function to get the settings value in settings.xml, BUT it doesn't work and I don't know why I've read this wiki -> https://wiki.multitheftauto.com/wiki/Settings_system and it should be work. This is what i've tried: - change "MySQLHost" to "*MySQLHost" <-- it doesn't work - change "MySQLHost" to "*joinpanel.MySQLHost" <-- it works! But that's not my goal. I want make this setting applied to all of the resources i had. It should be works if I'm not input the access modified and resource name This is settings.xml what I mean
  6. Hey, it works! Thanks Btw, could you resolve my another problem ? -> viewtopic.php?f=91&t=64828
  7. Yes. The map file is on the meta.xml "location.map" />
  8. Hi... I have a problem with getElementsByType. local location = getElementsByType ( "carjunk" ) print (#location) And this is my .map file <jobsystem> <carjunk x="1643.1171" y="-1515.9602" z="13.6608" /> <!-- Car junk LS - Dealer --> <carjunk x="2050.0410" y="-2493.8975" z="13.5469" /> <!-- Car junk LS - Airport --> <carjunk x="2449.2085" y="-2717.8171" z="1.2407" /> <!-- Car junk LS - Dock --> <carjunk x="-1936.1998" y="276.2972" z="41.0469" /> <!-- Car junk SF - Dealer --> <carjunk x="-1444.9786" y="-518.4357" z="13.8330" /> <!-- Car junk SF - Airport --> <carjunk x="-1650.2468" y="254.0446" z="-0.4856" /> <!-- Car junk SF - Dock --> <carjunk x="1406.0493" y="970.4077" z="10.8130" /> <!-- Car junk LV - Dealer --> <carjunk x="1370.8197" y="1769.5979" z="10.4103" /> <!-- Car junk LV - Airport --> <carjunk x="1628.2588" y="572.7244" z="-0.4549" /> <!-- Car junk LV - Dock --> </jobsystem> But, the return value is 0. I've already change theType on getElementsByType to jobsystem, but it's keep 0.
  9. I've tried a few methods. First, i tried to change the stats to 5000 because colt_cop's skill level is at 5000. addEventHandler('onPlayerSpawn', root, function() if not setPedStat(source,22,5000) then outputChatBox ( "Failed to set stats number: 22 with value: 5000", player, 255, 0, 0, false ) end end ) But the function return false. Second, i tried to change the flags from colt_cop to colt45. Then, i convert it to hex number with calc and place this code. But, the anim was going to be weird.
  10. It's doesn't work because I've already tried it before.
  11. Hi.... I wanna ask how to make one-handed weapon to two-handed. Btw, I have found something on weapon.dat. Is is possible to set it ? Sorry for my bad English
  12. Oh man... It's my fault. You're right about the meta hehe.... Thanks for help me
  13. Hi... I have a new problem with GUI (before case I've solved my problem) <- skip this This is my full code client.lua GUIEditor = { tab = {}, staticimage = {}, edit = {}, window = {}, tabpanel = {}, button = {}, label = {}, gridlist = {}, memo = {} } weaponShop = { } addEventHandler("onClientResourceStart", resourceRoot, function() local shopElements = getElementsByType ( "weapon" , getResourceRootElement() ) local num = 1 for k,v in ipairs(shopElements) do weaponShop[num] = { } weaponShop[num].ID = getElementData ( v, "id" ) weaponShop[num].Name = getElementData ( v, "name" ) weaponShop[num].Price = getElementData ( v, "price" ) weaponShop[num].WeaponID = getElementData ( v, "weaponid" ) weaponShop[num].Slot = getElementData ( v, "slot" ) weaponShop[num].PerClip = getElementData ( v, "perclip" ) weaponShop[num].PriceClip = getElementData ( v, "priceclip" ) local weapon = tonumber ( weaponShop[num].WeaponID ) weaponShop[num].WeaponRange = getWeaponProperty ( weapon, "pro", "weapon_range" ) weaponShop[num].TargetRange = getWeaponProperty ( weapon, "pro", "target_range" ) weaponShop[num].Damage = getWeaponProperty ( weapon, "pro", "damage" ) weaponShop[num].Accuracy = getWeaponProperty ( weapon, "pro", "accuracy" ) weaponShop[num].FiringSpeed = getWeaponProperty ( weapon, "pro", "firing_speed" ) weaponShop[num].WeaponSlot = getWeaponProperty ( weapon, "pro", "weapon_slot" ) num = num + 1 end GUIEditor.window[1] = guiCreateWindow(377, 185, 667, 313, "Ammu-Nation", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 22, 648, 281, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Weapon & Ammo", GUIEditor.tabpanel[1]) GUIEditor.gridlist[1] = guiCreateGridList(7, 7, 150, 155, false, GUIEditor.tab[1]) local column = guiGridListAddColumn(GUIEditor.gridlist[1], "Weapon", 0.9) local number = table.maxn ( weaponShop ) local iter = 1 for count = iter, number, 1 do local row = guiGridListAddRow(GUIEditor.gridlist[1]) local getname = tostring ( weaponShop[count].Name ) guiGridListSetItemText(GUIEditor.gridlist[1], row, column, "".. getname .."", false, false) end GUIEditor.staticimage[1] = guiCreateStaticImage(187, 59, 64, 64, "images/UNKNOWN.png", false, GUIEditor.tab[1]) GUIEditor.label[1] = guiCreateLabel(289, 9, 282, 15, "Weapon Name:", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(309, 24, 282, 15, "Weapon ID:", false, GUIEditor.tab[1]) GUIEditor.label[3] = guiCreateLabel(350, 39, 282, 15, "Slot:", false, GUIEditor.tab[1]) GUIEditor.label[4] = guiCreateLabel(293, 54, 282, 15, "Ammo per Clip:", false, GUIEditor.tab[1]) GUIEditor.label[5] = guiCreateLabel(289, 69, 282, 15, "Weapon Range:", false, GUIEditor.tab[1]) GUIEditor.label[6] = guiCreateLabel(299, 84, 282, 15, "Target Range:", false, GUIEditor.tab[1]) GUIEditor.label[7] = guiCreateLabel(330, 99, 282, 15, "Damage:", false, GUIEditor.tab[1]) GUIEditor.label[8] = guiCreateLabel(325, 114, 282, 15, "Accuracy:", false, GUIEditor.tab[1]) GUIEditor.label[9] = guiCreateLabel(307, 129, 282, 15, "Firing Speed:", false, GUIEditor.tab[1]) GUIEditor.label[10] = guiCreateLabel(349, 144, 282, 15, "Price: $", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(491, 215, 150, 31, "Buy", false, GUIEditor.tab[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") GUIEditor.button[2] = guiCreateButton(7, 215, 150, 31, "Armor: $250", false, GUIEditor.tab[1]) guiSetFont(GUIEditor.button[2], "default-bold-small") GUIEditor.label[11] = guiCreateLabel(311, 159, 282, 15, "Ammo Price: $ per clip", false, GUIEditor.tab[1]) GUIEditor.label[12] = guiCreateLabel(174, 221, 172, 15, "How many clips do you want ?", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(349, 215, 60, 27, "", false, GUIEditor.tab[1]) guiEditSetMaxLength(GUIEditor.edit[1], 2) GUIEditor.label[13] = guiCreateLabel(490, 186, 148, 15, "Total: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("About", GUIEditor.tabpanel[1]) GUIEditor.memo[1] = guiCreateMemo(9, 7, 633, 244, "Dibuat oleh: Rachmad Setiawan\nPenggunaan:\n\n- Klik senjata yang ingin dibeli.\n- Masukkan jumlah klip peluru yang ingin dibeli\n- Klik buy untuk membeli\n\nNB:\n* Pastikan jumlah uang mencukupi\n* Klik armor jika ingin membeli armor\n* Anda harus membayar senjatanya kalau sebelumnya tidak mempunyai senjata yang Anda ingin beli", false, GUIEditor.tab[2]) guiMemoSetReadOnly(GUIEditor.memo[1], true) end ) function updateWeaponShop ( row ) local num = row + 1 guiStaticImageLoadImage ( GUIEditor.staticimage[1], "images/" .. tostring ( weaponShop[num].ID ) .. ".png" ) guiSetText ( GUIEditor.label[1], "Weapon Name: " .. tostring ( weaponShop[num].WeaponName ) .. "" ) guiSetText ( GUIEditor.label[2], "Weapon ID: " .. tostring ( weaponShop[num].WeaponID ) .. "" ) guiSetText ( GUIEditor.label[3], "Slot: " .. tostring ( weaponShop[num].Slot ) .. "" ) guiSetText ( GUIEditor.label[4], "Ammo per Clip: " .. tostring ( weaponShop[num].PerClip ) .. "" ) guiSetText ( GUIEditor.label[5], "Weapon Range: " .. tostring ( weaponShop[num].WeaponRange ) .. "" ) guiSetText ( GUIEditor.label[6], "Target Range: " .. tostring ( weaponShop[num].TargetRange ) .. "" ) guiSetText ( GUIEditor.label[7], "Damage: " .. tostring ( weaponShop[num].Damage ) .. "" ) guiSetText ( GUIEditor.label[8], "Accuracy: " .. tostring ( weaponShop[num].Accuracy ) .. "" ) guiSetText ( GUIEditor.label[9], "Firing Speed: " .. tostring ( weaponShop[num].FiringSpeed ) .. "" ) guiSetText ( GUIEditor.label[10], "Price: $" .. tostring ( weaponShop[num].Price ) .. "" ) guiSetText ( GUIEditor.label[11], "Ammo Price: $" .. tostring ( weaponShop[num].PriceClip ) .. " per clip" ) if tonumber ( guiGetText ( GUIEditor.edit[1] ) ) > 0 then local input = tonumber ( guiGetText ( GUIEditor.edit[1] ) ) local getslot = tonumber ( weaponShop[num].WeaponSlot ) if getPedTotalAmmo ( localPlayer, getslot ) > 0 then if getPedWeapon ( localPlayer, getslot) == weaponShop[num].WeaponID then return guiSetText ( GUIEditor.label[13], "Total: $" .. ( tonumber ( weaponShop[num].PriceClip ) * input ) .. "" ) end end guiSetText ( GUIEditor.label[13], "Total: $" .. ( weaponShop[num].Price + ( tonumber ( weaponShop[num].PriceClip ) * input ) ) .. "" ) else guiSetText ( GUIEditor.label[13], "Total: $" ) end end addEventHandler("onClientGUIClick", root, function () if source == GUIEditor.gridlist[1] then local row,column = guiGridListGetSelectedItem ( source ) updateWeaponShop ( row ) end end ) addEventHandler("onClientGUIChanged", root, function () if source == GUIEditor.edit[1] then updateWeaponShop ( row ) end end ) addCommandHandler ( "Control Weapon Panel", function () guiGridListSetSelectedItem ( GUIEditor.gridlist[1], 0, 0 ) guiSetVisible ( GUIEditor.window[1], not guiGetVisible ( GUIEditor.window[1] ) ) showCursor ( guiGetVisible ( GUIEditor.window[1] ) ) guiSetInputMode ( "no_binds_when_editing" ) guiSetText ( GUIEditor.edit[1], "" ) end ) bindKey ( "n", "down", "Control Weapon Panel" ) And this is my error from clientscript.log [2013-04-28 23:17:17] WARNING: weaponshop\client.lua:88: Bad argument @ 'guiStaticImageLoadImage' [Expected gui-element at argument 1, got nil]
  14. I need help for my problem, please.
  15. I use a login system and the code it's same. login_register_window = guiCreateWindow(448,192,419,227,"MySQL Login System",false) guiWindowSetMovable(login_register_window,false) guiWindowSetSizable(login_register_window,false) tab_panel = guiCreateTabPanel(0.0859,0.1982,0.8282,0.7225,true,login_register_window) login_tab = guiCreateTab("Login",tab_panel) register_tab = guiCreateTab("Register",tab_panel) activation_tab = guiCreateTab("Activation",tab_panel) user_active_l = guiCreateEdit(0.2507,0.15,0.6311,0.2,"",true,activation_tab) code_edit_l = guiCreateEdit(0.2507,0.4143,0.634,0.1929,"",true,activation_tab) user_edit_l = guiCreateEdit(0.2507,0.15,0.6311,0.2,"",true,login_tab) pw_edit_l = guiCreateEdit(0.2507,0.4143,0.634,0.1929,"",true,login_tab) reg_edit_l = guiCreateEdit(0.2507,0.15,0.6311,0.2,"http://mta.cingka.com",true,register_tab) guiEditSetReadOnly ( reg_edit_l, true ) login_btn_l = guiCreateButton(0.2536,0.6643,0.634,0.2071,"Login",true,login_tab) guiSetFont(login_btn_l,"default-bold-small") login_active_l = guiCreateButton(0.2536,0.6643,0.634,0.2071,"Activate",true,activation_tab) guiSetFont(login_btn_l,"default-bold-small") username_label_l = guiCreateLabel(0.0317,0.1571,0.219,0.1929,"Username: ",true,login_tab) username_active_l = guiCreateLabel(0.0317,0.1571,0.219,0.1929,"Username: ",true,activation_tab) register_label_l = guiCreateLabel(0.0317,0.1571,0.219,0.1929,"Register: ",true,register_tab) guiLabelSetVerticalAlign(username_label_l,"center") guiLabelSetHorizontalAlign(username_label_l,"right",false) guiSetFont(username_label_l,"default-bold-small") guiLabelSetVerticalAlign(register_label_l,"center") guiLabelSetHorizontalAlign(register_label_l,"right",false) guiSetFont(register_label_l,"default-bold-small") guiLabelSetVerticalAlign(username_active_l,"center") guiLabelSetHorizontalAlign(username_active_l,"right",false) guiSetFont(username_active_l,"default-bold-small") pw_label_l = guiCreateLabel(0.0692,0.4286,0.17,0.1714," Password: ",true,login_tab) code_active_l = guiCreateLabel(0.0692,0.4286,0.17,0.1714," Code: ",true,activation_tab) guiLabelSetVerticalAlign(pw_label_l,"center") guiLabelSetHorizontalAlign(pw_label_l,"center",false) guiSetFont(pw_label_l,"default-bold-small") guiLabelSetVerticalAlign(code_active_l,"center") guiLabelSetHorizontalAlign(code_active_l,"center",false) guiSetFont(code_active_l,"default-bold-small") guiEditSetMasked( pw_edit_l, true ) guiSetVisible( login_register_window, false ) function playerJoin() guiSetText( user_active_l, getPlayerName(getLocalPlayer()) ) guiSetText( user_edit_l, getPlayerName(getLocalPlayer()) ) guiSetVisible( login_register_window, true ) showCursor( true ) guiSetInputEnabled( true ) setCameraMatrix( -1799.6999511719, 1856.5999755859, 30.39999961853, -1763.9000244141, 1852.5999755859, 19.799999237061 ) fadeCamera (true) end addEvent("onJoin", true) addEventHandler("onJoin", getRootElement(), playerJoin) function closeWindow() guiSetVisible( login_register_window, false ) showCursor( false ) guiSetInputEnabled( false ) end addEvent("closeWindow", true) addEventHandler("closeWindow", getRootElement(), closeWindow) function login_player ( source ) triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(user_edit_l), guiGetText(pw_edit_l) ) end addEventHandler("onClientGUIClick", login_btn_l, login_player,false) function activation_player ( source ) triggerServerEvent ( "onActivation", getRootElement(), localPlayer, guiGetText(user_active_l), guiGetText(code_edit_l) ) end addEventHandler("onClientGUIClick", login_active_l, activation_player,false) That script worked and I don't understand what's wrong
  16. No error and warning. No one buttons work.
  17. I also use Notepad++, I recommend using with Lua highlight. More information see this thread: https://forum.multitheftauto.com/viewto ... d3c651f384 Thanks for the information Btw, i have another problem. When I click the GUI button, it's nothing. Here's my new code. GUIEditor = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, checkbox = {} } function initializeBankPanel () GUIEditor.window[1] = guiCreateWindow(541, 262, 314, 226, "National Bank of San Andreas", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 21, 295, 196, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Deposit", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(20, 56, 247, 15, "Your balance: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Withdraw", GUIEditor.tabpanel[1]) GUIEditor.label[3] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[2]) GUIEditor.edit[2] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(20, 56, 248, 15, "Your balance: $", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[2]) GUIEditor.tab[3] = guiCreateTab("Transfer", GUIEditor.tabpanel[1]) GUIEditor.label[5] = guiCreateLabel(20, 19, 61, 15, "Username:", false, GUIEditor.tab[3]) GUIEditor.label[6] = guiCreateLabel(20, 52, 61, 15, "Amount: $", false, GUIEditor.tab[3]) GUIEditor.label[7] = guiCreateLabel(20, 88, 247, 15, "Your balance: $", false, GUIEditor.tab[3]) GUIEditor.edit[3] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.edit[4] = guiCreateEdit(85, 50, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.checkbox[1] = guiCreateCheckBox(270, 20, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.checkbox[2] = guiCreateCheckBox(270, 55, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.button[3] = guiCreateButton(88, 120, 124, 38, "Proceed", false, GUIEditor.tab[3]) end bindKey ( "]", "down", function () if isElement(GUIEditor.window[1]) then destroyElement(GUIEditor.window[1]) showCursor(false) guiSetInputEnabled(false) updateBalance ( ) else initializeBankPanel() showCursor(true) guiSetInputMode("no_binds_when_editing") updateBalance ( ) end end ) player = getLocalPlayer ( ) function updateBalance () guiSetText ( GUIEditor.label[2], "Your balance: $".. getElementData ( player, "data.bank" ) .."" ) guiSetText ( GUIEditor.label[4], "Your balance: $".. getElementData ( player, "data.bank" ) .."" ) guiSetText ( GUIEditor.label[7], "Your balance: $".. getElementData ( player, "data.bank" ) .."" ) end function deposit ( ) local text = guiGetText ( GUIEditor.edit[1] ) local amount = tonumber ( text ) if amount <= 0 or amount > getPlayerMoney ( ) then return guiShowMessageBox ( "Invalid value.", "error" ) end local operation = triggerServerEvent ( "depositMoney", getRootElement(), localPlayer, amount ) if operation then return guiShowMessageBox ( "Operation completed.", "info" ) else return guiShowMessageBox ( "Unknown error.", "error" ) end end function withdraw ( ) local text = guiGetText ( GUIEditor.edit[2] ) local amount = tonumber ( text ) if amount <= 0 or amount > tonumber ( getElementData ( player, "data.bank" ) ) then return guiShowMessageBox ( "Invalid value.", "error" ) end if getPlayerMoney ( ) + amount > 999999999 then return guiShowMessageBox ( "You can't carry that cash too much.", "error" ) end local operation = triggerServerEvent ( "withdrawMoney", getRootElement(), localPlayer, amount ) if operation then return guiShowMessageBox ( "Operation completed.", "info" ) else return guiShowMessageBox ( "Unknown error.", "error" ) end end function transfer ( ) local user = guiGetText ( GUIEditor.edit[3] ) local text = guiGetText ( GUIEditor.edit[4] ) local amount = tonumber ( text ) local oldbal = getElementData ( player, "data.bank" ) local newbal = tonumber ( oldbal ) if amount <= 0 then return guiShowMessageBox ( "Invalid value.", "error" ) end if amount > newbal then return guiShowMessageBox ( "You don't have that cash in your balance.", "error" ) end if user == nil then return guiShowMessageBox ( "Insert the username.", "error" ) end if user == getPlayerName ( player ) then return guiShowMessageBox ( "You can't transfer to yourself.", "error" ) end if guiCheckBoxGetSelected ( GUIEditor.checkbox[1] ) and guiCheckBoxGetSelected ( GUIEditor.checkbox[2] ) then for k,name in inpairs ( getElementsByType ( "player" ) ) do if name == user and getElementData ( getPlayerFromName ( user ), "loggedin" ) == 1 then local operation = triggerServerEvent ( "transferMoney", getRootElement(), localPlayer, user, amount ) if operation then return guiShowMessageBox ( "Operation completed.", "info" ) else return guiShowMessageBox ( "Unknown error.", "error" ) end end end else return guiShowMessageBox ( "You must check the boxes to confirm your input.", "error" ) end guiShowMessageBox ( "The player is not active right now.", "error" ) end addEventHandler("onClientGUIClick", GUIEditor.button[1], deposit, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], withdraw, false) addEventHandler("onClientGUIClick", GUIEditor.button[3], transfer, false) addEventHandler("onClientGUITabSwitched", getRootElement ( ), updateBalance, false) addEvent("showBankPanel", true) addEvent("closeBankPanel", true) addEvent("initializeBankPanel", true) addEventHandler("showBankPanel", getRootElement(), showBankPanel) addEventHandler("closeBankPanel", getRootElement(), closeBankPanel) addEventHandler("initializeBankPanel", getRootElement(), initializeBankPanel)
  18. Thanks. Now the GUI worked properly Then, which script editor i must use ? MTA script editor ? (I use notepad++)
  19. Thanks. But,I can't close the GUI now (no error and warning)
  20. I don't get any errors or warnings.
  21. Hi... I have a problem with GUI. The GUI doesn't appear with bindKey I already searching every topic discuss about GUI and i tried to follow the method, but it's nothing GUIEditor = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, checkbox = {} } function initializeBankPanel () GUIEditor.window[1] = guiCreateWindow(541, 262, 314, 226, "National Bank of San Andreas", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 21, 295, 196, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Deposit", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(20, 56, 247, 15, "Your balance: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Withdraw", GUIEditor.tabpanel[1]) GUIEditor.label[3] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[2]) GUIEditor.edit[2] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(20, 56, 248, 15, "Your balance: $", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[2]) GUIEditor.tab[3] = guiCreateTab("Transfer", GUIEditor.tabpanel[1]) GUIEditor.label[5] = guiCreateLabel(20, 19, 61, 15, "Username:", false, GUIEditor.tab[3]) GUIEditor.label[6] = guiCreateLabel(20, 52, 61, 15, "Amount: $", false, GUIEditor.tab[3]) GUIEditor.label[7] = guiCreateLabel(20, 88, 247, 15, "Your balance: $", false, GUIEditor.tab[3]) GUIEditor.edit[3] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.edit[4] = guiCreateEdit(85, 50, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.checkbox[1] = guiCreateCheckBox(270, 20, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.checkbox[2] = guiCreateCheckBox(270, 55, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.button[3] = guiCreateButton(88, 120, 124, 38, "Proceed", false, GUIEditor.tab[3]) end function startToBindKey ( ) bindKey ( "]", "down", function () guiSetVisible ( GUIEditor.window[1], not guiGetVisible ( GUIEditor.window[1] ) ) showCursor ( guiGetVisible ( GUIEditor.window[1] ) ) guiSetInputEnabled ( guiGetVisible ( GUIEditor.window[1] ) ) end } initializeBankPanel() end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startToBindKey ) player = getLocalPlayer ( ) gettab = getSelectedTab ( GUIEditor.tabpanel[1] ) function controlBankPanel ( ) if not isElement ( GUIEditor.window[1] ) then initializeBankPanel () end if not guiGetVisible ( GUIEditor.window[1] ) then showBankPanel ( ) else closeBankPanel ( ) end end function updateBalance () guiSetText ( GUIEditor.label[2], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[4], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[7], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) end function showBankPanel () guiSetVisible ( GUIEditor.window[1], true ) showCursor ( true ) guiSetInputEnabled ( true ) updateBalance ( ) end function closeBankPanel() guiSetVisible ( GUIEditor.window[1], false ) showCursor ( false ) guiSetInputEnabled ( false ) end addEventHandler("onClientGUIClick", GUIEditor.button[1], deposit, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], withdraw, false) addEventHandler("onClientGUIClick", GUIEditor.button[3], transfer, false) addEventHandler("onClientGUITabSwitched", getRootElement ( ), updateBalance, false) addEvent("showBankPanel", true) addEvent("closeBankPanel", true) addEventHandler("showBankPanel", getRootElement(), showBankPanel) addEventHandler("closeBankPanel", getRootElement(), closeBankPanel) Thx for ur attention and your help
×
×
  • Create New...