Jump to content

jingzhi

Members
  • Posts

    288
  • Joined

  • Last visited

Everything posted by jingzhi

  1. Hey Ty very much but can this function retrieve specific string from the webpage or only download some file?
  2. Sorry, last pic was token badly, basically what I want to do is to make an ammunition with cart system, when you check out you pay the total money and get all the weapon you got in your cart, please help, I'm stuck here for long time
  3. Hey guys! So I want to retrieve the world time from internet, and then show them in my server, is this possible? I have checked on google but I got confused, any pro on lua, please help, thank you very much!
  4. Hey JR10, thank you for your help again, now it's partly working, but the big problem remains. What I'm trying to do is, to make a ammunation system with cart like this It should take the total money from player and give the player weapons he bought that was in the cart Thank you again
  5. I read on the wiki, that "while" loops the function when it meet the circumstance that follows it
  6. Hey, the gridlist is a cart, when the player press buy button, we need to give him the weapons in the cart and take his money
  7. So I'm trying to make a script for ammunation using gridlist and saving values in tables, I wrote this script, when I test it my computer dies, please help to check where's wrong weapontable = { } ammotable = { } pricetable = { } function table.size(tab) local length = 0 for _ in pairs(tab) do length = length + 1 end return length end addEventHandler("onClientResourceStart", resourceRoot, function() local screenW, screenH = guiGetScreenSize() AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) guiWindowSetSizable(AmmoMenu, false) AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) guiEditSetMaxLength(AmmountTextbox, 6) BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) guiSetFont(BuyButton, "default-bold-small") guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) guiSetFont(QuitButton, "default-bold-small") guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3) AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu) Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) guiSetFont(Infolabel, "default-bold-small") guiGridListSetSortingEnabled (Cartlist,false) guiSetVisible(AmmoMenu,false) end ) function chooseweapon() if source == TazerImage then setElementData(localPlayer,"WeaponChosen",23) end if source == PistolImage then setElementData(localPlayer,"WeaponChosen",22) end if source == DeserteagleImage then setElementData(localPlayer,"WeaponChosen",24) end if source == Ak47Image then setElementData(localPlayer,"WeaponChosen",30) end if source == UziImage then setElementData(localPlayer,"WeaponChosen",28) end if source == Tec9Image then setElementData(localPlayer,"WeaponChosen",32) end if source == Mp5Image then setElementData(localPlayer,"WeaponChosen",29) end if source == Spas12Image then setElementData(localPlayer,"WeaponChosen",27) end if source == M4Image then setElementData(localPlayer,"WeaponChosen",31) end if source == BuyButton then if guiGridListGetRowCount(Cartlist) > 0 then local count = 0 while count <= guiGridListGetRowCount(Cartlist) do local count = count + 1 for count,price in pairs(pricetable) do local totalprice = totalprice + price if count == guiGridListGetRowCount(Cartlist) then if getPlayerMoney(localPlayer) >= totalprice then while count <= guiGridListGetRowCount(Cartlist) do for count,id in pairs(weapontable) do for count,ammo in pairs(ammotable) do triggerServerEvent(localPlayer,"giveweapon",resourceRoot,localPlayer,id,ammo) end end end takePlayerMoney(localPlayer,totalprice) else outputChatBox("You don't have enough money!",localPlayer,255,0,0) end end end end takePlayerMoney(buyer,totalprice) else outputChatBox("You don't have anything in your cart!",255,0,0) end end if source == QuitButton then showCursor(false) guiSetVisible(AmmoMenu,false) guiGridListClear (Cartlist) guiSetText (AmmountTextbox,"") for id,weaponid in pairs(weapontable) do weapontable[k]=nil end for id,ammo in pairs(ammotable) do ammotable[k]=nil end for id,price in pairs(pricetable) do pricetable[k]=nil end end if source == AddcartButton then if getElementData(localPlayer,"WeaponChosen") ~= false then if tonumber(guiGetText(AmmountTextbox)) ~= nil then if tonumber(guiGetText(AmmountTextbox)) > 0 then if tonumber(guiGetText(AmmountTextbox)) == math.floor(guiGetText(AmmountTextbox)) then local row = guiGridListAddRow(Cartlist) table.insert(weapontable,getElementData(localPlayer,"WeaponChosen")) table.insert(ammotable,guiGetText(AmmountTextbox)) table.insert(pricetable,math.floor(10 * guiGetText(AmmountTextbox))) guiGridListSetItemText(Cartlist,row,Weaponcolumn,""..getWeaponNameFromID(getElementData(localPlayer,"WeaponChosen")),false,false) guiGridListSetItemText(Cartlist,row,Amountcolumn,""..guiGetText(AmmountTextbox),false,false) guiGridListSetItemText(Cartlist,row,Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox))),false,false) else outputChatBox("Please enter a integer!",255,0,0) end else outputChatBox("Please enter a positive number!",255,0,0) end else outputChatBox("Please enter a integer as the ammount of ammo",255,0,0) end else outputChatBox("Please choose a weapon by clicking on the icon of it",255,0,0) end end end addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) addEvent("showweaponGUI",true) function showGUI() totalprice = 0 outputChatBox("true") showCursor(true) guiSetVisible(AmmoMenu,true) end addEventHandler("showweaponGUI",getRootElement(),showGUI)
  8. I have put the functions to load the mod
  9. function download(resource) if resource == getThisResource() then outputChatBox("Download started") downloadFile("rhino.txd") downloadFile("rhino.dff") end end addEventHandler("onClientResourceStart",getRootElement(),download) function replacemod(success) if success == true then local txd = engineLoadTXD ( "rhino.txd" ) local dff = engineLoadDFF ( "rhino.dff", 432 ) engineImportTXD ( txd, 432 ) engineReplaceModel ( dff, 432 ) else outputChatBox("Download was failed") end end addEventHandler("onClientFileDownloadComplete",getRootElement(),replacemod) This is the full code
  10. I used outputChatbox to see and it says it's failed
  11. Yeah, I guess i should use variables and thank you
  12. Too bad you didn't include that line, or edited the apparent error message, since it looks like it originates from line 28, not 46.http://www.lua.org/manual/5.1/manual.ht ... math.atan2 math.atan2 has two arguments, not just one. math.atan2 ((copx - prisonerx) / (copy - prisonery)) --extract of line 28 I have deleted some part of the scripts before i post it here, i will try out your fix later, thank you
  13. I made it as you said now the "file doesnt exist" is gone but the download is still a failure
  14. local teamLaw = { ["Police"] = true, ["Speed Enforcement"] = true } function arrest(arrester,nightstick) if arrester then if getElementType(arrester) == "player" then local Team = getPlayerTeam(arrester) local TeamName = Team and getTeamName(Team) if(teamLaw[TeamName]) then if nightstick == 3 then outputChatBox("weapon value correct") if getPlayerWantedLevel(source) > 0 then setTimer(criminalarrested,100,0,arrester,source) end end end end end end addEventHandler("onPlayerDamage",getRootElement(),arrest) function criminalarrested(arrester,criminal) local copx, copy, copz = getElementPosition (arrester) local prisonerx, prisonery, prisonerz = getElementPosition (criminal) local copangle = (360 - math.deg (math.atan2 ((copx - prisonerx) / (copy - prisonery)))) % 360 setElementRotation(criminal,_,_,copangle) setCameraTarget(criminal, arrester) local dist = getDistanceBetweenPoints2D (copx, copy, prisonerx, prisonery) if dist < 2 then setControlState(criminal,"forwards", false) setControlState(criminal,"sprint", false ) else setControlState(criminal,"forwards", true) setControlState(criminal"sprint", true ) end end Hey guys im trying to make a police arresting system that if cop hit with wanted people with nightstick the wanted should be cuffed and follow the police, but this doesn't work, in the debugscript it says " :46: bad argument #2 to atan2(number expected, got no value)"
  15. Scripts function download(resource) if resource == getThisResource() then outputChatBox("Download started") downloadFile("rhino.txd") downloadFile("rhino.dff") end end addEventHandler("onClientResourceStart",getRootElement(),download) meta "JingZhi" type="script" /> Hey guys I know I have asked a lot of questions these day, please don't get annoyed cause i'm a noobie, and noobies need help So i am trying to make this ingame downloader, but it always say the file doesnt exist, is there any problem in my scipts?
  16. I see what you mean but im not really sure how to do it, can you show me?
  17. I am making a script for ammunation, and I want to also make a cart for the ammunation. I made a gridlist for cart, and a buy button. Is there any way to make it like, when I press "Buy" and then i buy every item in the cart? And is there anyway to make it like, if there is already this kind of ammo in the cart, it won't create another row for these ammo, but will combine with the other same type of ammo? (like i have 10 m4 now in my cart, i want to add 10 more, then i have 20 m4 ammos but not 2 rows of 10 m4 ammos) Please help, thank y'all Here is my scripts Server local weaponmarker = createMarker(296.42404,-38.29199,1000.5,"cylinder",1.5,0,255,0) setElementInterior(weaponmarker,1) function showClientGUI(marker) if marker == weaponmarker then if getTeamName(getPlayerTeam(source)) ~= "Criminal" then triggerClientEvent(source,"showweaponGUI",source) else outputChatBox("Ammunation won't sell guns&ammos to criminals, buy it in black market",source,255,0,0) end end end addEventHandler("onPlayerMarkerHit",getRootElement(),showClientGUI) addEvent("GiveWeapon",true) addEventHandler("GiveWeapon",getRootElement(), function(buyer,quantity) if getPlayerMoney(buyer) >= math.floor(quantity * 10) then giveWeapon(buyer,getElementData(buyer,"WeaponChosen"),quantity) takePlayerMoney(buyer,math.floor(quantity * 10)) else outputChatBox("You don't have enough money for this",buyer,255,0,0) end end) Client addEventHandler("onClientResourceStart", resourceRoot, function() local screenW, screenH = guiGetScreenSize() AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) guiWindowSetSizable(AmmoMenu, false) AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) guiEditSetMaxLength(AmmountTextbox, 6) BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) guiSetFont(BuyButton, "default-bold-small") guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) guiSetFont(QuitButton, "default-bold-small") guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3) AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu) Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) guiSetFont(Infolabel, "default-bold-small") guiGridListSetSortingEnabled (Cartlist,false) guiSetVisible(AmmoMenu,false) end ) function chooseweapon() if source == TazerImage then setElementData(localPlayer,"WeaponChosen",23) end if source == PistolImage then setElementData(localPlayer,"WeaponChosen",22) end if source == DeserteagleImage then setElementData(localPlayer,"WeaponChosen",24) end if source == Ak47Image then setElementData(localPlayer,"WeaponChosen",30) end if source == UziImage then setElementData(localPlayer,"WeaponChosen",28) end if source == Tec9Image then setElementData(localPlayer,"WeaponChosen",32) end if source == Mp5Image then setElementData(localPlayer,"WeaponChosen",29) end if source == Spas12Image then setElementData(localPlayer,"WeaponChosen",27) end if source == M4Image then setElementData(localPlayer,"WeaponChosen",31) end if source == BuyButton then if guiGridListGetRowCount(Cartlist) > 0 then triggerServerEvent("GiveWeapon",resourceRoot,localPlayer,guiGetText(AmmountTextbox)) else outputChatBox("You don't have anything in your cart!",255,0,0) end end if source == QuitButton then showCursor(false) guiSetVisible(AmmoMenu,false) guiGridListClear (Cartlist) guiSetText (AmmountTextbox,"") end if source == AddcartButton then if getElementData(localPlayer,"WeaponChosen") ~= false then if tonumber(guiGetText(AmmountTextbox)) > 0 and tonumber(guiGetText(AmmountTextbox)) ~= nil then local row = guiGridListAddRow(Cartlist) guiGridListSetItemText(Cartlist,row,Weaponcolumn,""..getWeaponNameFromID(getElementData(localPlayer,"WeaponChosen")),false,false) guiGridListSetItemText(Cartlist,row,Amountcolumn,""..guiGetText(AmmountTextbox),false,false) guiGridListSetItemText(Cartlist,row,Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox))),false,false) else outputChatBox("Please enter a integer as the ammount of ammo",255,0,0) end else outputChatBox("Please choose a weapon by clicking on the icon of it",255,0,0) end end end addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) addEvent("showweaponGUI",true) function showGUI() outputChatBox("true") showCursor(true) guiSetVisible(AmmoMenu,true) end addEventHandler("showweaponGUI",getRootElement(),showGUI)
  18. It still got the same problem, when I walk in, nothing happens
  19. Client side addEventHandler("onClientResourceStart", resourceRoot, function() local screenW, screenH = guiGetScreenSize() AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) guiWindowSetSizable(AmmoMenu, false) AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) guiEditSetMaxLength(QuantityTextbox, 6) BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) guiSetFont(BuyButton, "default-bold-small") guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) guiSetFont(QuitButton, "default-bold-small") guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3) AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu) Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) guiSetFont(Infolabel, "default-bold-small") guiGridListSetSortingEnabled (Cartlist,false) guiSetVisible(AmmoMenu,false) end ) function chooseweapon() if source == TazerImage then setElementData(localPlayer,"WeaponChosen",23) end if source == PistolImage then setElementData(localPlayer,"WeaponChosen",22) end if source == DeserteagleImage then setElementData(localPlayer,"WeaponChosen",24) end if source == Ak47Image then setElementData(localPlayer,"WeaponChosen",30) end if source == UziImage then setElementData(localPlayer,"WeaponChosen",28) end if source == Tec9Image then setElementData(localPlayer,"WeaponChosen",32) end if source == Mp5Image then setElementData(localPlayer,"WeaponChosen",29) end if source == Spas12Image then setElementData(localPlayer,"WeaponChosen",27) end if source == M4Image then setElementData(localPlayer,"WeaponChosen",31) end if source == BuyButton then if guiGridListGetRowCount(Cartlist) > 0 then triggerServerEvent("GiveWeapon",resourceRoot,localPlayer,guiGetText(AmmountTextbox)) else outputChatBox("You don't have anything in your cart!",localPlayer,255,0,0) end end if source == QuitButton then showCursor(false) guiSetVisible(AmmoMenu,false) guiGridListClear (Cartlist) guiSetText (AmmountTextbox,"") end if source == AddcartButton then if getElementData("weaponprice") ~= false then if tonumber(guiGetText(AmmountTextbox)) > 0 and tonumber(guiGetText(AmmountTextbox)) ~= nil then guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Weaponcolumn,..getWeaponNameFromID(getElementData(localPlayer,"WeaponChosen"))) guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Amountcolumn,..guiGetText(AmmountTextbox)..) guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox)))) else outputChatBox("Please enter a integer as the ammount of ammo",localPlayer,255,0,0) end else outputChatBox("Please choose a weapon by clicking on the icon of it",localPlayer,255,0,0) end end end addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) addEvent("showweaponGUI",true) function showGUI(player) if getElementType(player) == "player" then outputChatBox("true") showCursor(true) guiSetVisible(AmmoMenu,true) end end addEventHandler("showweaponGUI",getRootElement(),showGUI) Server Side local weaponmarker = createMarker(296.42404,-38.29199,1000.5,"cylinder",1.5,0,255,0) setElementInterior(weaponmarker,1) function showClientGUI(marker) if marker == weaponmarker then if getTeamName(getPlayerTeam(source)) ~= "Criminal" then triggerClientEvent(source,"showweaponGUI",resourceRoot,source) else outputChatBox("Ammunation won't sell guns&ammos to criminals, buy it in black market",source,255,0,0) end end end addEventHandler("onPlayerMarkerHit",getRootElement(),showClientGUI) addEvent("GiveWeapon",true) addEventHandler("GiveWeapon",getRootElement(), function(buyer,quantity) if getPlayerMoney(buyer) >= math.floor(quantity * 10) then giveWeapon(buyer,getElementData(buyer,"WeaponChosen"),quantity) takePlayerMoney(buyer,math.floor(quantity * 10)) else outputChatBox("You don't have enough money for this",buyer,255,0,0) end end) I am trying to make the GUI for ammunation, but now when i walk in the marker the GUI doesn't show, please help and thanks
×
×
  • Create New...