Jump to content

Price.

Members
  • Posts

    244
  • Joined

  • Last visited

Everything posted by Price.

  1. the GUI is the only thing iam missing but...... iam not good with GUI's
  2. well I had this script and I'am not that good with gui's so basically I want to attach a police chief script to a GUI instead of some commands, for example i want to "sack some officer" like to get him off duty with time so he cant join the police force until this period of time is passed function giveHeadOfficerRights(admin, commandName, accountName) local accName = getAccountName( getPlayerAccount( admin )) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" )) then if accountName then local account = getAccount( accountName ) local policeChief = getAccountPlayer( account ) if account and policeChief then if not getAccountData( account, "isPoliceChief" ) then setElementData( policeChief, "isPoliceChief", true ) setAccountData( account, "isPoliceChief", true ) outputChatBox( "Player: "..getPlayerName(policeChief).." was successfully added as police chief", admin, 0, 200, 0 ) else setElementData( policeChief, "isPoliceChief", false ) setAccountData( account, "isPoliceChief", false ) outputChatBox( "Player: "..getPlayerName(policeChief).." was removed from police chief", admin, 255, 200, 0 ) end end else outputChatBox ("Correct syntax: /addpc ", playerSource) end end end addCommandHandler( "addpc", giveHeadOfficerRights) addCommandHandler( "removepc", giveHeadOfficerRights) function kickBadPolice(policeChief, commandName, badOfficer) if getElementData( policeChief, "isPoliceChief" ) then local cop = getPlayerFromName( badOfficer ) if cop then setElementData( cop, "bannedFromLaw", true ) outputChatBox( "You have been kicked from the force by: "..getPlayerName(policeChief), cop, 255, 0, 0) outputChatBox( "Police: "..badOfficer.." was kicked from the police job", policeChief, 0, 200, 0 ) -- Reset job and team local unemployed = getTeamFromName( "Unemployed" ) setPlayerTeam( cop, unemployed ) setPlayerNametagColor( cop, 255, 255, 0 ) setElementData( cop, "admin",false) local skinID = exports["clothes"]:getBoughtSkin ( cop ) setElementModel( cop, skinID ) setElementData( cop, "Occupation", "" ) else outputChatBox( "Correct syntax: /rj ", policeChief, 255, 200, 0 ) end end end addCommandHandler( "rj", kickBadPolice ) function allowPoliceJob(policeChief, commandName, badOfficer) if getElementData( policeChief, "isPoliceChief" ) then local cop = getPlayerFromName( badOfficer ) if cop then setElementData( cop, "bannedFromLaw", false ) outputChatBox( "You have been unblocked from law jobs by: "..getPlayerName(policeChief), cop, 0, 255, 0) outputChatBox( "Police: "..badOfficer.." was unbanned from the police job", policeChief, 0, 200, 0 ) else outputChatBox( "Correct syntax: /cj ", policeChief, 255, 200, 0 ) end end end addCommandHandler( "cj", allowPoliceJob ) there is a GUI here but its from community script so has different functions function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end GUIEditor_Button = {} GUIEditor_Label = {} wnd = guiCreateWindow(0.32,0.175,0.5138,0.7583,"Police Chief Panel",true) guiWindowSetMovable(wnd,false) guiWindowSetSizable(wnd,false) centerWindow(wnd) grid = guiCreateGridList(9,25,183,375,false,wnd) guiGridListSetSelectionMode(grid,1) guiGridListAddColumn(grid,"Players",0.-- s8) --> edit = guiCreateEdit(9,406,182,40,"",false,wnd) GUIEditor_Button[1] = guiCreateButton(196,33,205,34,"Sack Selected",false,wnd) GUIEditor_Button[2] = guiCreateButton(196,79,205,34,"Unsack Selected",false,wnd) GUIEditor_Button[3] = guiCreateButton(196,125,205,34,"Place APB",false,wnd) GUIEditor_Button[4] = guiCreateButton(196,174,205,34,"/gochief",false,wnd) GUIEditor_Button[5] = guiCreateButton(315,397,87,49,"Close window",false,wnd) guiSetFont(GUIEditor_Button[5],"default-bold-small") guiSetProperty(GUIEditor_Button[5],"NormalTextColour","ffff0000") GUIEditor_Label[6] = guiCreateLabel(199,333,201,27,"Skin:",false,wnd) guiSetVisible(wnd,false) for i,btn in ipairs(GUIEditor_Button) do guiSetFont(btn,"default-bold-small") guiSetProperty(btn,"NormalTextColour","ffff0000") end for i,lal in ipairs(GUIEditor_Label) do guiSetFont(lal,"default-bold-small") guiLabelSetColor(lal,255,255,0) end function open() triggerServerEvent("isPolice",localPlayer) end bindKey(key,"down",open) addEvent("Yes",true) addEventHandler("Yes",root, function () if guiGetVisible(wnd) then guiSetVisible(wnd,false) showCursor(false) guiSetInputEnabled(false) else guiSetVisible(wnd,true) showCursor(true) guiSetInputEnabled(true) putAllPlayersInList() end end ) function putAllPlayersInList() guiGridListClear(grid) for i,v in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid,row,1,getPlayerName(v),false,false) guiGridListSetItemColor(grid,row,1,0,255,0) end end addEventHandler("onClientGUIClick",root, function () if ( source == GUIEditor_Button[5] ) then guiSetVisible(wnd,false) showCursor(false) guiSetInputEnabled(false) end end ) function setPlayerSep(player) setCameraTarget(player) x,y = guiGetScreenSize() endkey = guiCreateButton(0.1,0.4,0.1,0.15,"End",true) addEventHandler("onClientGUIClick",endkey,onEndSep,false) end function onEndSep() destroyElement(endkey) setCameraTarget(localPlayer) end addEventHandler("onClientGUIClick",root, function () local sel = guiGridListGetSelectedItem(grid) local text = guiGridListGetItemText(grid,sel,1) if ( source == GUIEditor_Button[2] ) then if ( sel ~= -1 ) then setPlayerSep(getPlayerFromName(text)) else show("Please Choose Player To Spectator it") end elseif ( source == GUIEditor_Button[1] ) then if ( sel ~= -1 ) then triggerServerEvent("killPlayer",localPlayer,text) else show("Please Choose Player To Kill it") end elseif ( source == GUIEditor_Button[3] ) then if ( sel ~= -1 ) then local player = getPlayerFromName(text) if isPedInVehicle(player) then triggerServerEvent("onDes",localPlayer,text) else show("This Player Don't Have Vehicle") end else show("Please Choose Player To Destroy His Vehicle") end elseif ( source == GUIEditor_Button[4] ) then if ( sel ~= -1 ) then local player = getPlayerFromName(text) if isPedInVehicle(player) then triggerServerEvent("onBlow",localPlayer,text) else show("This Player Don't Have Vehicle") end else show("Please Choose Player To Blow His Vehicle") end end end ) addEventHandler("onClientGUIClick",root, function () if ( source == grid ) then local sel = guiGridListGetSelectedItem(grid) local text = guiGridListGetItemText(grid,sel,1) local player = getPlayerFromName(text) if ( player ) then guiSetText(GUIEditor_Label[1],"Name: " .. getPlayerName(player)) guiSetText(GUIEditor_Label[2],"Money: " .. getPlayerMoney(player) .. "$") guiSetText(GUIEditor_Label[3],"Ping: " .. getPlayerPing(player)) guiSetText(GUIEditor_Label[4],"Health: " .. math.ceil(getElementHealth(player)) .. "%") guiSetText(GUIEditor_Label[5],"Armor: " .. math.ceil(getPedArmor(player)) .. "%") guiSetText(GUIEditor_Label[6],"Skin: " .. getElementModel(player)) else guiSetText(GUIEditor_Label[1],"Name: N/A") guiSetText(GUIEditor_Label[2],"Money: N/A") guiSetText(GUIEditor_Label[3],"Ping: N/A") guiSetText(GUIEditor_Label[4],"Health: N/A") guiSetText(GUIEditor_Label[5],"Armor: N/A") guiSetText(GUIEditor_Label[6],"Skin: N/A") end end end ) addEventHandler("onClientGUIChanged",root, function () if ( source == edit ) then local text = guiGetText(edit) if ( text == "" ) then putAllPlayersInList() else guiGridListClear(grid) for i,v in ipairs(getElementsByType("player")) do local name = getPlayerName(v) if string.find(name,text) then local row = guiGridListAddRow(grid) guiGridListSetItemText(grid,row,1,name,false,false) guiGridListSetItemColor(grid,row,1,255,255,0) end end end end end ) Again i just want instead of commands to be attached to gui like this sack button, I want when I press sack another gui opens and tell me for how long and reason then he gets to "Civilian" team and cannot join the force till the period of time is finished, and /gochief I want it to be attached to /gochief button
  3. sorry , made a double post by mistake
  4. edit: forgot to add server file to Meta.xml, worst mistake ever... thanks for everything guys I really appreciate it
  5. I called my self Price in-game, does it add "|AFK" beside your name? I'am testing on local server on MTA
  6. sorry for double reply but uhm as I said I wanted to do as when i do /afk a text |AFK gets added BESIDES his name not to change his entire name to AFK but to put |AFK besides his name, and actually Nothing really happens with the code so we are trying to debug the script manually still nothing happens.
  7. k changed the texts only, it doesnt matter as long as it doesn't show anything in char nor /debugscript 3 not even in server console Client function afkCommand() outputDebugString("testing this section") local theVehicle = getPedOccupiedVehicle ( localPlayer ) local level = getPlayerWantedLevel ( localPlayer ) if ( level > 0 ) then outputChatBox("You cannot go AFK while being wanted!", 255, 255, 255) else if theVehicle then outputChatBox("You must be on foot to use this command.", 255, 255, 255) else if isPedOnGround(localPlayer) then if getElementDimension(localPlayer) < 10 then outputDebugString("trying to figure it out") triggerServerEvent("afkStatus",localPlayer,true) outputDebugString("just another test") outputChatBox("You will be AFK in 5 seconds" , 255, 255, 255) setTimer( function() setElementDimension(localPlayer, math.random(10, 1000)) setElementFrozen(localPlayer, true) end, 5000, 1 ) else outputChatBox("You must be on the ground to use this command.", 255,255,255) end end end end end addCommandHandler("afk", afkCommand) function returnafk (button, press, r, g, b ) if (press) then if button == "w" or button == "s" or button == "d" or button == "a" then local dimPlr = getElementDimension(localPlayer) if ((dimPlr >= 10) and (dimPlr <= 1000)) then outputDebugString("random text") triggerServerEvent("afkStatus",localPlayer,false) outputDebugString("another test") setElementDimension(localPlayer, 0) setElementFrozen(localPlayer, false) outputChatBox("You are no longer AFK", 255, 255, 255) end end end end addEventHandler("onClientKey", root, returnafk) addEvent("afkStatus",true) addEventHandler("afkStatus",root, function (status) outputDebugString("serverside part executed") if status then setPlayerName (client,getPlayerName(client).. "|AFK") outputDebugString("set to afk") else local name = string.gsub(getPlayerName(client),"|AFK", "") if name then outputDebugString("set to not afk") setPlayerName (client,name) end end end)
  8. same nothing client function afkCommand() outputDebugString("set to not afk") local theVehicle = getPedOccupiedVehicle ( localPlayer ) local level = getPlayerWantedLevel ( localPlayer ) if ( level > 0 ) then outputChatBox("You cannot go AFK while being wanted!", 255, 255, 255) else if theVehicle then outputChatBox("You must be on foot to use this command.", 255, 255, 255) else if isPedOnGround(localPlayer) then if getElementDimension(localPlayer) < 10 then outputDebugString("set to not afk") triggerServerEvent("afkStatus",localPlayer,true) outputDebugString("set to not afk") outputChatBox("You will be AFK in 5 seconds" , 255, 255, 255) setTimer( function() setElementDimension(localPlayer, math.random(10, 1000)) setElementFrozen(localPlayer, true) end, 5000, 1 ) else outputChatBox("You must be on the ground to use this command.", 255,255,255) end end end end end addCommandHandler("afk", afkCommand) function returnafk (button, press, r, g, b ) if (press) then if button == "w" or button == "s" or button == "d" or button == "a" then local dimPlr = getElementDimension(localPlayer) if ((dimPlr >= 10) and (dimPlr <= 1000)) then outputDebugString("set to not afk") triggerServerEvent("afkStatus",localPlayer,false) outputDebugString("set to not afk") setElementDimension(localPlayer, 0) setElementFrozen(localPlayer, false) outputChatBox("You are no longer AFK", 255, 255, 255) end end end end addEventHandler("onClientKey", root, returnafk) server addEvent("afkStatus",true) addEventHandler("afkStatus",root, function (status) outputDebugString("serverside part executed") if status then setPlayerName (client,getPlayerName(client).. "|AFK") outputDebugString("set to afk") else local name = string.gsub(getPlayerName(client),"|AFK", "") if name then outputDebugString("set to not afk") setPlayerName (client,name) end end end)
  9. same nothing appears client: function afkCommand() outputDebugString local theVehicle = getPedOccupiedVehicle ( localPlayer ) local level = getPlayerWantedLevel ( localPlayer ) if ( level > 0 ) then outputChatBox("You cannot go AFK while being wanted!", 255, 255, 255) else if theVehicle then outputChatBox("You must be on foot to use this command.", 255, 255, 255) else if isPedOnGround(localPlayer) then if getElementDimension(localPlayer) < 10 then outputDebugString triggerServerEvent("afkStatus",localPlayer,true) outputDebugString outputChatBox("You will be AFK in 5 seconds" , 255, 255, 255) setTimer( function() setElementDimension(localPlayer, math.random(10, 1000)) setElementFrozen(localPlayer, true) end, 5000, 1 ) else outputChatBox("You must be on the ground to use this command.", 255,255,255) end end end end end addCommandHandler("afk", afkCommand) function returnafk (button, press, r, g, b ) if (press) then if button == "w" or button == "s" or button == "d" or button == "a" then local dimPlr = getElementDimension(localPlayer) if ((dimPlr >= 10) and (dimPlr <= 1000)) then outputDebugString triggerServerEvent("afkStatus",localPlayer,false) outputDebugString setElementDimension(localPlayer, 0) setElementFrozen(localPlayer, false) outputChatBox("You are no longer AFK", 255, 255, 255) end end end end addEventHandler("onClientKey", root, returnafk) server outputDebugString addEvent("afkStatus",true) addEventHandler("afkStatus",root, function (status) if status then setPlayerName (client,getPlayerName(client).. "|AFK") else local name = string.gsub(getPlayerName(client),"|AFK", "") outputDebugString if name then setPlayerName (client,name) end end end) PS: the afk is related to chat, like when you say any word having any of these letters"A,W,S or D" you get back from AFK
  10. still nothing, should it be added like that? Client: function afkCommand() ouputDebugString("write here which part of the code get executed") local theVehicle = getPedOccupiedVehicle ( localPlayer ) local level = getPlayerWantedLevel ( localPlayer ) if ( level > 0 ) then outputChatBox("You cannot go AFK while being wanted!", 255, 255, 255) else if theVehicle then outputChatBox("You must be on foot to use this command.", 255, 255, 255) else if isPedOnGround(localPlayer) then if getElementDimension(localPlayer) < 10 then triggerServerEvent("afkStatus",localPlayer,true) outputChatBox("You will be AFK in 5 seconds" , 255, 255, 255) setTimer( function() setElementDimension(localPlayer, math.random(10, 1000)) setElementFrozen(localPlayer, true) end, 5000, 1 ) else outputChatBox("You must be on the ground to use this command.", 255,255,255) end end end end end addCommandHandler("afk", afkCommand) function returnafk (button, press, r, g, b ) if (press) then if button == "w" or button == "s" or button == "d" or button == "a" then local dimPlr = getElementDimension(localPlayer) if ((dimPlr >= 10) and (dimPlr <= 1000)) then triggerServerEvent("afkStatus",localPlayer,false) setElementDimension(localPlayer, 0) setElementFrozen(localPlayer, false) outputChatBox("You are no longer AFK", 255, 255, 255) end end end end addEventHandler("onClientKey", root, returnafk)
  11. nothing in debug and my name doesnt change Client function afkCommand() local theVehicle = getPedOccupiedVehicle ( localPlayer ) local level = getPlayerWantedLevel ( localPlayer ) if ( level > 0 ) then outputChatBox("You cannot go AFK while being wanted!", 255, 255, 255) else if theVehicle then outputChatBox("You must be on foot to use this command.", 255, 255, 255) else if isPedOnGround(localPlayer) then if getElementDimension(localPlayer) < 10 then triggerServerEvent("afkStatus",localPlayer,true) outputChatBox("You will be AFK in 5 seconds" , 255, 255, 255) setTimer( function() setElementDimension(localPlayer, math.random(10, 1000)) setElementFrozen(localPlayer, true) end, 5000, 1 ) else outputChatBox("You must be on the ground to use this command.", 255,255,255) end end end end end addCommandHandler("afk", afkCommand) function returnafk (button, press, r, g, b ) if (press) then if button == "w" or button == "s" or button == "d" or button == "a" then local dimPlr = getElementDimension(localPlayer) if ((dimPlr >= 10) and (dimPlr <= 1000)) then triggerServerEvent("afkStatus",localPlayer,false) setElementDimension(localPlayer, 0) setElementFrozen(localPlayer, false) outputChatBox("You are no longer AFK", 255, 255, 255) end end end end addEventHandler("onClientKey", root, returnafk) server addEvent("afkStatus",true) addEventHandler("afkStatus",root, function (status) if status then setPlayerName (client,getPlayerName(client).. "|AFK") else local name = string.gsub(getPlayerName(client),"|AFK", "") if name then setPlayerName (client,name) end end end)
  12. oooooh wow, such a stupid mistake . thanks for solving this for me, uhm just 1 more thing I wanted to try that if you do /afk too you get |AFK beside your name but I got no idea to start with
  13. tried removing all definitions from function and got this 1 only error line 13: bad argument @'outputChatbox"[Expected number at argument 2, got player function afkCommand() local theVehicle = getPedOccupiedVehicle ( localPlayer ) local level = getPlayerWantedLevel ( localPlayer ) if ( level > 0 ) then outputChatBox("You cannot go AFK while being wanted!", localPlayer, 255, 255, 255) else if theVehicle then outputChatBox("You must be on foot to use this command.", localPlayer, 255, 255, 255) else if isPedOnGround(localPlayer) then if getElementDimension(localPlayer) < 10 then outputChatBox("You will be AFK in 5 seconds", localPlayer, 255, 255, 255) setTimer( function() setElementDimension(localPlayer, math.random(10, 1000)) setElementFrozen(localPlayer, true) end, 5000, 1 ) end else outputChatBox("You must be on the ground to use this command.", localPlayer, 255, 255, 255) end end end end addCommandHandler("afk", afkCommand) function returnafk (button, press, r, g, b ) if (press) then if button == "w" or button == "s" or button == "d" or button == "a" then local dimPlr = getElementDimension(localPlayer) if ((dimPlr >= 10) and (dimPlr <= 1000)) then setElementDimension(localPlayer, 0) setElementFrozen(localPlayer, false) outputChatBox("You are no longer AFK", localPlayer, 255, 255, 255) end end end end addEventHandler("onClientKey", root, returnafk)
  14. did the same you requested and its already in client side, same.
  15. line 3: bad argument @'getPedOccupiedVehicle' [Expected ped at argument 1, got string 'afk'] line 11: Bad argument @'isPedonGround [Expected ped at argument 1, got string 'afk'] line 22: bad argument @'outputchatbox' [Expected bool at argument 5, got number '255'] I've tried using localplayer and thePlayer, both same result
  16. so basically I was trying to make that if you do /afk you go to another dimension and when you press W ,S,D or A buttons, you get back to main dimension as you're back from afk, but idk got some errors when I put local player gives me error Line 32: attempt to compare a number with boolean line 31: Bad argument @ 'getElementDimension' [expected element at argument 1, got nil] and some errors when i do /afk line 7: Bad argument @ 'isPedinVehicle' [Expected ped at argument 1, got string 'afk'] same error at line 2 'getPedOccupiedVehicle same @ line 10:'isPedonGround' function afkCommand(thePlayer, cmd, r, g, b) local theVehicle = getPedOccupiedVehicle ( thePlayer ) local level = getPlayerWantedLevel ( thePlayer ) if ( level > 0 ) then outputChatBox("You cannot go AFK while being wanted!", thePlayer, 255, 255, 255) else if isPedInVehicle(thePlayer) then outputChatBox("You must be on foot to use this command.", thePlayer, 255, 255, 255) else if isPedOnGround(thePlayer) then if getElementDimension(thePlayer) < 10 then outputChatBox("You will be AFK in 5 seconds", thePlayer, 255, 255, 255) setTimer( function() setElementDimension(thePlayer, math.random(10, 1000)) setElementFrozen(thePlayer, true) end, 5000, 1 ) end else outputChatBox("You must be on the ground to use this command.", thePlayer, 255, 255, 255) end end end end addCommandHandler("afk", afkCommand) function returnafk (button, press, thePlayer, r, g, b ) if (press) then if button == "w" or button == "s" or button == "d" or button == "a" then local dimPlr = getElementDimension(thePlayer) if ((dimPlr >= 10) and (dimPlr <= 1000)) then setElementDimension(thePlayer, 0) setElementFrozen(thePlayer, false) outputChatBox("You are no longer AFK", thePlayer, 255, 255, 255) end end end end addEventHandler("onClientKey", root, returnafk)
  17. if you did that then its going off limits example: you have 30 people, 30 x 5 = 150 so its goin offlimits
  18. Price.

    Big Problem

    attach the timer like this exports.scoreboard:addScoreboardColumn('Level') addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) local myExp = exports.exp_system:getAccountLevel ( account ) if isGuestAccount(account) then return end local Level = exports.exp_system:getAccountLevel (account,"Level") if Level then setElementData(source, "Level", tostring(Level)) else setElementData(source,"Level",0) end end) setTimer ( function'sName, 5000, 1 ) If you dont have a function's name add one to execute the timer correctly.
  19. try using this function Cube(button, state, absX, absY, wx, wy, wz, element) if getElementData(getLocalPlayer(), "exclusiveGUI") then return end if element and getElementType( element ) == "object" and button == "right" and state == "down" and getElementModel(element) == "ELEMENTID" then local x, y, z = getElementPosition(localPlayer) if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz) <= 3 then if (wRightClick) then hideregister() end showCursor(true) ax = absX ay = absY register = element showregister() end end end addEventHandler("onClientClick", getRootElement(), Cube, true)
  20. Price.

    Play Time Help

    the last 2 lines (66, 67) put each addEventHandler under each function.
  21. Price.

    [HELP] Please

    yes without function please? you don't create a table with function or eventhandler.
  22. again there is no such event called "onZombieWasted" try using OnPedWasted
×
×
  • Create New...