Jump to content

Khalil

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by Khalil

  1. Khalil

    How to do ?

    No. Use this to show the GUI bindKey ( "--button--", "down", showGUI ) Then this to hide it bindKey ( "--button--", "up", hideGUI )
  2. It is already defined, clientside.
  3. localPlayer is clientsided, use source.
  4. Client: theMarker = createMarker(2144.6176757813,-1688.2725830078,14.0859375, "cylinder", 2, 204, 0, 204,170) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} function guiMyCwindow(w,h,t) local x,y = guiGetScreenSize() return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) end drugWindow = guiMyCwindow(301,250,"Buy Drugs") guiSetVisible(drugWindow, false) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,drugWindow) GUIEditor_Button[1] = guiCreateButton(179,200,110,36,"Cancel",false,drugWindow) GUIEditor_Label[2] = guiCreateLabel(19,33,273,50,"Weed ( x 5 )",false,drugWindow) guiLabelSetColor( GUIEditor_Label[2], 0,255,0 ) GUIEditor_Label[3] = guiCreateLabel(19,50,273,50,"Speed ( x 5 )",false,drugWindow) guiLabelSetColor( GUIEditor_Label[3], 204,0,204 ) GUIEditor_Label[4] = guiCreateLabel(19,67,273,50,"Eroine ( x 5 )",false,drugWindow) guiLabelSetColor( GUIEditor_Label[4], 255,255,0 ) GUIEditor_Label[5] = guiCreateLabel(19,84,273,50,"LSD ( x 5 )",false,drugWindow) guiLabelSetColor( GUIEditor_Label[5], 0,0,255 ) GUIEditor_Label[6] = guiCreateLabel(19,101,273,50,"God ( x 5 )",false,drugWindow) guiLabelSetColor( GUIEditor_Label[6], 255,0,0 ) GUIEditor_Button[2] = guiCreateButton(95,33,70,15,"1000$",false,drugWindow) GUIEditor_Button[3] = guiCreateButton(95,50,70,15,"1500$",false,drugWindow) GUIEditor_Button[4] = guiCreateButton(95,67,70,15,"1200$",false,drugWindow) GUIEditor_Button[5] = guiCreateButton(95,84,70,15,"800$",false,drugWindow) GUIEditor_Button[6] = guiCreateButton(95,101,70,15,"2000$",false,drugWindow) function openDrugGui ( localPlayer ) guiSetVisible(drugWindow, true) showCursor(true) end addEventHandler ( "onClientMarkerHit", getRootElement(), openDrugGui ) function removeDrugWindow() guiSetVisible(drugWindow, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , removeDrugWindow, false) function buyWeed(localPlayer) local pMoney = getPlayerMoney(localPlayer) if ( pMoney > 1000 ) then triggerServerEvent("takemoney",localPlayer) end end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , buyWeed, false) Server: function moneyTake() takePlayerMoney(source,1000) end addEvent("takemoney",true) addEventHandler("takemoney",getRootElement(),moneyTake)
  5. oh lol that was a mistake.. so I have this now: function search() for index, player in ipairs ( getElementsByType ( 'player' ) ) do if ( player ~= localPlayer ) then local search = guiGetText(searchBar) string.match(index,search) end end end addEventHandler("onClientGUIChanged",searchBar,search)
  6. Ok so, I have this: function search() for index, player in ipairs ( getElementsByType ( 'player' ) ) do if ( player ~= localPlayer ) then local item = guiGridListGetSelectedItem(gridList) local player = guiGridListGetItemText(gridList,item,0) local search = guiGetText(searchBar) string.match(player,search) end end end addEventHandler("onClientGUIChanged",searchBar,search) How do I remove all the other rows and just have the matched player(s)?
  7. How exactly do I do that?
  8. How do I make it like lil_Toady's admin panel? I made a gridlist, got all the server players in there, and added an editbox.
  9. Works fine thanks Also, when a player leaves the server, the gridlist should automatically refresh, how do I do that?
  10. Hello. I made a gridlist to get all players in the server. I do the command to open the gui and it looks fine. I close the gui, and open it again, then I find three of the same player on the gridlist, I don't know what to do, here's the code: function showGUI ( ) local tostate = not guiGetVisible ( win ) guiSetVisible ( win, tostate ) showCursor ( tostate ) for index, player in ipairs ( getElementsByType ( 'player' ) ) do if ( player ~= localPlayer ) then guiGridListSetItemText ( gridList, guiGridListAddRow ( gridList ), 1, getPlayerName ( player ), false, false ) end end end addCommandHandler("aj",showGUI)
  11. Whatever I do, whenever I use getZoneName, only the zone appears and not the city. local x,y,z = getElementPosition (lp) location = getZoneName ( x, y, z, false) guiSetText(memoThree,location) I even changed location = getZoneName ( x, y, z, false) to location = getZoneName ( x, y, z, true) But still, the city isn't put in the memo, just the zone...
  12. local x,y,z = getElementPosition (lp) guiSetText(memo,math.round(x,3)..","..math.round(y,3)..","..math.round(z,3)) Debug Script says: "attempt to call field 'round' a nil value"
  13. Is it possible to disable clicking on a gridlist's column title?
  14. local lp = getLocalPlayer ( ) local marker = createMarker ( 2043, 1557, 10, "cylinder", 2.0, 0, 0, 255, 0 ) local ped = createPed ( 59, 2043, 1557, 10 ) createBlipAttachedTo ( marker, 25 ) sx, sy = guiGetScreenSize () win = guiCreateWindow(282, 212, 462, 285, "Drug Dealer Job Description", false) guiWindowSetSizable(win, false) buttonCancel = guiCreateButton(49, 236, 119, 39, "Cancel", false, win) buttonAccept = guiCreateButton(270, 236, 119, 39, "Accept", false, win) memoOne = guiCreateMemo(9, 24, 443, 206, "Spawn a boat and go to the marker on your map. Buy some drugs and go to the next marker to sell your drugs.", false, win) guiMemoSetReadOnly(memoOne, true) guiSetVisible ( win, false ) drugsWindow = guiCreateWindow(328, 235, 455, 304, "Drugs Market", false) guiWindowSetSizable(drugsWindow, false) gridList = guiCreateGridList(9, 25, 429, 216, false, drugsWindow) guiGridListAddColumn(gridList, "Drug", 0.3) guiGridListAddColumn(gridList, "Buy for", 0.3) guiGridListAddColumn(gridList, "Sell for", 0.3) for i = 1, 5 do guiGridListAddRow(gridList) end meth = guiGridListSetItemText(gridList, 0, 1, "Meth", false, false) guiGridListSetItemText(gridList, 0, 2, "$500,000", false, false) guiGridListSetItemText(gridList, 0, 3, "$750,000", false, false) cocaine = guiGridListSetItemText(gridList, 1, 1, "Cocaine", false, false) guiGridListSetItemText(gridList, 1, 2, "$50,000", false, false) guiGridListSetItemText(gridList, 1, 3, "$100,000", false, false) heroin = guiGridListSetItemText(gridList, 2, 1, "Heroin", false, false) guiGridListSetItemText(gridList, 2, 2, "$25,000", false, false) guiGridListSetItemText(gridList, 2, 3, "$40,000", false, false) ecstasy = guiGridListSetItemText(gridList, 3, 1, "Ecstasy", false, false) guiGridListSetItemText(gridList, 3, 2, "$15,000", false, false) guiGridListSetItemText(gridList, 3, 3, "$25,000", false, false) marijuana = guiGridListSetItemText(gridList, 4, 1, "Marijuana", false, false) guiGridListSetItemText(gridList, 4, 2, "$5,000", false, false) guiGridListSetItemText(gridList, 4, 3, "$7,500", false, false) guiGridListSetSelectionMode ( gridList, 0 ) buttonCancelTwo = guiCreateButton(38, 247, 118, 47, "Cancel", false, drugsWindow) buttonBuy = guiCreateButton(263, 247, 118, 47, "Buy", false, drugsWindow) guiSetVisible ( drugsWindow, false ) function openGUI ( p ) if ( getElementType ( p ) ~= 'player' or p ~= localPlayer ) then return end if ( getElementModel (lp) ) == 59 then outputChatBox ( "You already have this job", 255, 0, 0 ) return end guiSetVisible ( win, true ) showCursor ( true ) end addEventHandler("onClientMarkerHit", marker, openGUI ) addEventHandler ("onClientGUIClick",root, function () if (source == buttonCancel ) then guiSetVisible ( win, false ) showCursor ( false ) elseif (source == buttonAccept ) then guiSetVisible ( win, false ) showCursor ( false ) triggerServerEvent ("setTeam", lp) setElementModel ( lp, 59 ) drugsMarker = createMarker ( 2048, 1584, 10, "cylinder", 2.0, 255, 0, 0, 255 ) createBlipAttachedTo ( drugsMarker, 41, 2, 255, 0, 0, 255, 0, 65535 ) addEventHandler("onClientMarkerHit", drugsMarker, openDrugsGUI ) end end ) function invPed() cancelEvent() end addEventHandler("onClientPedDamage", ped, invPed) function openDrugsGUI ( p ) if ( getElementType ( p ) == "player" and p == lp ) then guiSetVisible ( drugsWindow, true ) showCursor ( true ) end end addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == buttonCancelTwo ) then guiSetVisible ( drugsWindow, false ) showCursor ( false ) elseif ( source == buttonBuy ) then guiSetVisible ( drugsWindow, false ) showCursor ( false ) outputChatBox ( "Go to the marker to sell your drugs" ) destroyElement ( drugsMarker ) drugBought = guiGridListGetSelectedItem ( gridList ) if ( drugBought == meth ) then if ( getPlayerMoney ( ) >= 500000 ) then triggerServerEvent ( "takeMoney", lp, 500000 ) else outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) end elseif ( drugBought == cocaine ) then if ( getPlayerMoney ( ) >= 50000 ) then triggerServerEvent ( "takeMoney", lp, 50000 ) else outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) end elseif ( drugBought == heroin ) then if ( getPlayerMoney ( ) >= 25000 ) then triggerServerEvent ( "takeMoney", lp, 25000 ) else outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) end elseif ( drugBought == ecstasy ) then if ( getPlayerMoney ( ) >= 15000 ) then triggerServerEvent ( "takeMoney", lp, 15000 ) else outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) end elseif ( drugBought == marijuana ) then if ( getPlayerMoney ( ) >= 5000 ) then triggerServerEvent ( "takeMoney", lp, 5000 ) else outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) end end end end ) SERVER local CrimTeam = createTeam ( "Criminal" ) function takejob () if ( CrimTeam ) then outputChatBox ( "Go to the marker to buy drugs", source, 0, 255, 0 ) setPlayerTeam(source, CrimTeam ) end end addEvent ( "setTeam", true ) addEventHandler ( "setTeam", root, takejob ) function moneyTake () outputChatBox ( "Go to the marker to sell your drugs", source ) end addEvent ("takeMoney", true) addEventHandler ( "takeMoney", root, moneyTake ) Still no money is taken from the player.. Also, it doesn't even check if the player has enough money or not, but it still outputs "Go to the marker to sell your drugs"...
  15. I did this if ( getPlayerMoney ( ) >= 50000 ) then triggerServerEvent ( "cocaineMoney", lp ) and methMoney etc. and this is serverside function cocaineMoney () takePlayerMoney ( 50000, source ) end addEvent ("cocaineMoney", true) addEventHandler ( "cocaineMoney", root, cocaineMoney ) Still doesnt work, no money is taken..
  16. But it is both client and server. Oh well, just gonna use it server side. Thanks
  17. Now, "takePlayerMoney" doesn't work when I click Buy
  18. Umm, now, whenever I press any button on any GUI, it outputs in the chatbox "You don't have enough money for that".
  19. Firstly, when I click 'buttonAccept', I don't get moved to the Criminal Team. Debug says Bad Argument @ setPlayerTeam Also, debug says :109: ')' expected to close '(' at line 84 near 'elseif' Here is the code SERVER SIDE local CrimTeam = createTeam ( "Criminal" ) function takejob (source) getPlayerName(source) if ( CrimTeam ) then outputChatBox ( "Go to the marker to buy drugs", source, 0, 255, 0 ) setPlayerTeam(source, CrimTeam ) end end addEvent ( "setTeam", true ) addEventHandler ( "setTeam", root, takejob ) CLIENT SIDE local lp = getLocalPlayer ( ) local marker = createMarker ( 2043, 1557, 10, "cylinder", 2.0, 0, 0, 255, 0 ) local ped = createPed ( 59, 2043, 1557, 10 ) createBlipAttachedTo ( marker, 25 ) sx, sy = guiGetScreenSize () win = guiCreateWindow(282, 212, 462, 285, "Drug Dealer Job Description", false) guiWindowSetSizable(win, false) buttonCancel = guiCreateButton(49, 236, 119, 39, "Cancel", false, win) buttonAccept = guiCreateButton(270, 236, 119, 39, "Accept", false, win) memoOne = guiCreateMemo(9, 24, 443, 206, "Spawn a boat and go to the marker on your map. Buy some drugs and go to the next marker to sell your drugs.", false, win) guiMemoSetReadOnly(memoOne, true) guiSetVisible ( win, false ) drugsWindow = guiCreateWindow(328, 235, 455, 304, "Drugs Market", false) guiWindowSetSizable(drugsWindow, false) gridList = guiCreateGridList(9, 25, 429, 216, false, drugsWindow) guiGridListAddColumn(gridList, "Drug", 0.3) guiGridListAddColumn(gridList, "Buy for", 0.3) guiGridListAddColumn(gridList, "Sell for", 0.3) for i = 1, 5 do guiGridListAddRow(gridList) end meth = guiGridListSetItemText(gridList, 0, 1, "Meth", false, false) guiGridListSetItemText(gridList, 0, 2, "$500,000", false, false) guiGridListSetItemText(gridList, 0, 3, "$750,000", false, false) cocaine = guiGridListSetItemText(gridList, 1, 1, "Cocaine", false, false) guiGridListSetItemText(gridList, 1, 2, "$50,000", false, false) guiGridListSetItemText(gridList, 1, 3, "$100,000", false, false) heroin = guiGridListSetItemText(gridList, 2, 1, "Heroin", false, false) guiGridListSetItemText(gridList, 2, 2, "$25,000", false, false) guiGridListSetItemText(gridList, 2, 3, "$40,000", false, false) ecstasy = guiGridListSetItemText(gridList, 3, 1, "Ecstasy", false, false) guiGridListSetItemText(gridList, 3, 2, "$15,000", false, false) guiGridListSetItemText(gridList, 3, 3, "$25,000", false, false) marijuana = guiGridListSetItemText(gridList, 4, 1, "Marijuana", false, false) guiGridListSetItemText(gridList, 4, 2, "$5,000", false, false) guiGridListSetItemText(gridList, 4, 3, "$7,500", false, false) guiGridListSetSelectionMode ( gridlist, 0 ) buttonCancelTwo = guiCreateButton(38, 247, 118, 47, "Cancel", false, drugsWindow) buttonBuy = guiCreateButton(263, 247, 118, 47, "Buy", false, drugsWindow) guiSetVisible ( drugsWindow, false ) function openGUI ( p ) if ( getElementType ( p ) ~= 'player' or p ~= localPlayer ) then return end if ( getElementModel (lp) ) == 59 then outputChatBox ( "You already have this job", 255, 0, 0 ) return end guiSetVisible ( win, true ) showCursor ( true ) end addEventHandler("onClientMarkerHit", marker, openGUI ) addEventHandler ("onClientGUIClick",root, function () if (source == buttonCancel ) then guiSetVisible ( win, false ) showCursor ( false ) elseif (source == buttonAccept ) then guiSetVisible ( win, false ) showCursor ( false ) triggerServerEvent ("setTeam", lp) setElementModel ( lp, 59 ) drugsMarker = createMarker ( 2048, 1584, 10, "cylinder", 2.0, 255, 0, 0, 255 ) createBlipAttachedTo ( drugsMarker, 41, 2, 255, 0, 0, 255, 0, 65535 ) addEventHandler("onClientMarkerHit", drugsMarker, openDrugsGUI ) end end ) function invPed() cancelEvent() end addEventHandler("onClientPedDamage", ped, invPed) function openDrugsGUI ( p ) if ( getElementType ( p ) == "player" and p == lp ) then guiSetVisible ( drugsWindow, true ) showCursor ( true ) end end addEventHandler ("onClientGUIClick",root, function () if (source == buttonCancelTwo ) then guiSetVisible ( win, false ) showCursor ( false ) elseif (source == buttonBuy ) then guiSetVisible ( win, false ) showCursor ( false ) outputChatBox ( "Go to the marker to sell your drugs" ) destroyElement ( drugsMarker ) drugBought = guiGridListGetSelectedItem ( gridList ) if (drugBought == meth) then if (getPlayerMoney ( )) >= 500000 then takePlayerMoney ( 500000 ) end elseif ((getPlayerMoney ( )) < 500000) then outputChatBox ("You don't have enough money for that", 255, 0, 0 ) end elseif (drugBought == Cocaine) then if (getPlayerMoney ( )) >= 50000 then takePlayerMoney ( 50000 ) end elseif ((getPlayerMoney ( )) < 50000) then outputChatBox ("You don't have enough money for that", 255, 0, 0 ) end end elseif (drugBought == heroin) then if (getPlayerMoney ( )) >= 25000 then takePlayerMoney ( 25000 ) end elseif (getPlayerMoney < 25000) then outputChatBox ("You don't have enough money for that", 255, 0, 0 ) end elseif (drugBought == ecstasy) then if (getPlayerMoney ( )) >= 15000 then takePlayerMoney (15000) end elseif (getPlayerMoney < 15000) then outputChatBox ("You don't have enough money for that", 255, 0, 0 ) end elseif (drugBought == marijuana) then if (getPlayerMoney >= 5000) then takePlayerMoney (5000) end elseif (getPlayerMoney < 5000) outputChatBox ("You don't have enough money for that", 255, 0, 0 ) end end )
  20. Khalil

    LUA Help.

    Debug says: :28:'end' expected (to close 'function' on line 23) near 'elseif'. local lp = getLocalPlayer ( ) sx, sy = guiGetScreenSize () win = guiCreateWindow( ( sx / 2 - 524 / 2 ), ( sy / 2 - 320 / 2 ), 524, 320, "Car Options", false) buttonOne = guiCreateButton(72, 98, 119, 66, "Engine", false, win) buttonTwo = guiCreateButton(309, 99, 119, 66, "Lights", false, win) buttonThree = guiCreateButton(500, 23, 15, 15, "X", false, win) buttonFour = guiCreateEdit(142, 240, 263, 29, "", false, win) buttonFive = guiCreateLabel(67, 246, 75, 15, "License Plate:", false, win) buttonSix = guiCreateButton(405, 240, 59, 31, "Set", false, win) buttonSeven = guiCreateLabel(148, 271, 219, 32, "Maximum 8 characters\nSetting your license plate costs $1000.", false, win) buttonEight = guiCreateButton(200, 165, 99, 52, "Lock", false, win) guiSetVisible(win,false) bindKey ( "f2", "down", function ( ) if ( isPedInVehicle ( lp ) == false or getVehicleController ( getPedOccupiedVehicle ( lp ) ) ~= lp ) then return end local tostate = not guiGetVisible ( win ) guiSetVisible ( win, tostate ) showCursor ( tostate ) end) addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == buttonThree ) then guiSetVisible ( win, false ) showCursor ( false ) end elseif ( source == buttonSix ) then local veh = getPedOccupiedVehicle ( lp ) if( veh ) then triggerServerEvent ( "onVehicleLisenceChange", lp, guiGetText ( buttonFour ) ) end end elseif ( source == buttonEight ) then executeCommandHandler ( "lock" ) elseif ( source == buttonOne ) then if ( isVehicleDamageProof ( theVehicle ) ) then return end guiSetEnabled ( buttonOne, false ) setTimer( guiSetEnabled, 2000, 1, buttonOne, true ) local veh = getPedOccupiedVehicle ( lp ) if ( veh and getVehicleController ( veh ) == lp ) then local state = not getVehicleEngineState ( veh ) setVehicleEngineState ( veh, state ) if ( state ) then playSound ( "start.mp3" ) outputChatBox ( "You have started your car's engine.", 231, 0, 0 ) else playSound ( "stop.mp3" ) outputChatBox ( "You have stopped your car's engine.", 231, 0, 0 ) end end elseif ( source == buttonTwo ) then triggerServerEvent ( "onVehicleLightStateChange", lp ) elseif ( source == buttonSix ) then local text = guiGetText ( butonFour ) local veh = getPedOccupiedVehicle ( lp ) if( veh ) then triggerServerEvent ( "onVehicleLisenceChange", lp, guiGetText ( buttonFour ) ) end end addEvent ( "onVehicleLightStateChange", true ) addEventHandler ( "onVehicleLightStateChange", root, function ( state, x, y, z ) if ( state ) then SoundPath = "on.mp3" else SoundPath = "on.mp3" end playSound3D ( "on.mp3", x, y, z ) end )
  21. Khalil

    LUA Help.

    Alright, thanks.
  22. Khalil

    LUA Help.

    But, will that player be able to switch weapons?
×
×
  • Create New...