Jump to content

Adde

Members
  • Posts

    228
  • Joined

  • Last visited

Everything posted by Adde

  1. Hello, I have my panel here where it supposed to be showing player names in the gridlist. I did exactly as I read on wiki and in another topic but it wont work. Nothing in debug can anyone see the problem? just so you know, this: GUIEditor = { tab = {}, tabpanel = {}, button = {}, label = {}, window = {}, gridlist = {} } is not the problem, i just removed all labels and buttons to make it easier to read. client GUIEditor = { tab = {}, tabpanel = {}, button = {}, label = {}, window = {}, gridlist = {} } local x, y = guiGetScreenSize() GUIEditor.window[11] = guiCreateWindow(1389/1920*x, 359/1080*y, 475, 506, "Staff panel", false) guiWindowSetSizable(GUIEditor.window[11], false) guiSetVisible(GUIEditor.window[11], false) guiSetProperty(GUIEditor.window[11], "CaptionColour", "FFFF0000") GUIEditor.tabpanel[1] = guiCreateTabPanel(10, 23, 455, 473, false, GUIEditor.window[11]) GUIEditor.tab[11] = guiCreateTab("Players", GUIEditor.tabpanel[1]) GUIEditor.gridlist[1] = guiCreateGridList(9, 10, 187, 428, false, GUIEditor.tab[11]) guiGridListSetSelectionMode(GUIEditor.gridlist[1], 2) column = guiGridListAddColumn(GUIEditor.gridlist[1], "Player Name", 1) function Refresh () guiGridListClear ( GUIEditor_gridlist[1] ) if column then for id,playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_gridlist[1]) guiGridListSetItemText(GUIEditor_gridlist[1], row, column, getPlayerName(playeritem), false, false) end end end addEventHandler ( "onClientPlayerJoin", getRootElement(), Refresh ) addEventHandler ( "onClientPlayerQuit", getRootElement(), Refresh ) addEventHandler ( "onClientPlayerChangeNick", getRootElement(), Refresh )
  2. Ye that´s it! Why didn´t I test that before, hah. but thx
  3. Hey, I got my jail system here and everything works without "triggerServerEvent("freefromthejail", source). Anyone can help me? If I change source to root, the whole server is being fucked. server error, markers everywere, guis being opened, etc. client: x, y = guiGetScreenSize() function startMission() MissionTimer1 = exports.missiontimer:createMissionTimer ( 10000, true, "%m:%s" , 0.8/2*x, 0.8/2*y, true, "default-bold", 5, 255, 10, 10 ) addEventHandler ( "onClientMissionTimerElapsed", getRootElement(), freeFromJail) end addEvent("setMissionTimer", true) addEventHandler("setMissionTimer", getLocalPlayer(), startMission) function freeFromJail() if MissionTimer1 then destroyElement(MissionTimer1) outputChatBox(getLocalPlayer(source).. "has been released from jail", getLocalPlayer(), 0, 240, 0) triggerServerEvent("freefromthejail", source) end end server: kreward = 150 function policeJob ( attacker, attackerweapon, bodypart, loss ) if attacker and getElementType(attacker) == "player" then theTeam = getPlayerTeam ( attacker ) local wlevel = getPlayerWantedLevel( source ) theSkin = getElementModel ( attacker ) if (attackerweapon == 3) and (loss > 2 ) and (wlevel > 0) then if getTeamName( theTeam ) == "Police Department" or getTeamName( theTeam ) == "Staff" or getTeamName( theTeam ) == "US Army" or getTeamName( theTeam ) == "US Marines" then setElementPosition ( source, 264.74, 77.69, 1001.03 ) setElementInterior ( source, 6 ) setElementDimension ( source, 3 ) toggleControl(source, "fire", false) toggleControl(source, "next_weapon", false) toggleControl(source, "previous_weapon", false) toggleControl(source, "aim_weapon", false) toggleControl(source, "vehicle_fire", false) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) outputChatBox ( "You have been jailed by "..theCop.. " for 5 minutes.", source ) outputChatBox ( "You have jailed "..theName, attacker ) local thisreward = wlevel*kreward givePlayerMoney ( attacker, thisreward ) setPlayerWantedLevel ( source, 0) triggerClientEvent("setMissionTimer", source) end end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) function freeJail() setElementPosition ( source, 1541.66, -1353.80, 329.5 ) setElementInterior ( source, 0 ) setElementDimension ( source, 0 ) toggleControl(source, "fire", true) toggleControl(source, "next_weapon", true) toggleControl(source, "previous_weapon", true) toggleControl(source, "aim_weapon", true) toggleControl(source, "vehicle_fire", true) end addEvent("freefromthejail", true) addEventHandler("freefromthejail", getRootElement(), freeJail)
  4. Adde

    missionTimer

    Client:5: addEventHandler [ expected element at argument 2, got nil ] It works to jail a person, but the timer don´t show on the screen in jail and it doesn´t even start. You never get out of jail.
  5. Adde

    missionTimer

    Still "addEventHandler [ expected element at argument 2, got nil ]"
  6. Adde

    draw dx text

    Thx! I got it working.
  7. Adde

    draw dx text

    Hello, I have a problem with this script. It doesn´t show the current level on the screen. It says attempt to call global theLevel (a nil value). Is something wrong with getElementData? function showLevel() theLevel = getElementData(source, "Level") color = tocolor(0,255,0,255) levelcolor = tocolor(255,255,0,255) dxDrawText("Current Level:", x*0.78, y*0.46, 0, 0, color, 3) dxDrawText("" ..theLevel, x*0.905, y*0.46, 0, 0, levelcolor, 3) end function HandleTheRendering ( ) addEventHandler("onClientRender", getRootElement(), showLevel) end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering)
  8. Adde

    missionTimer

    Ah okay. Now my script looks like: client: function setTimer() MissionTimer = exports.missionTimer:createMissionTimer ( 300000, true, "%m:%s" , 0.5, 0.5, true, "default-bold", 5, 255, 10, 10 ) setElementVisibleTo ( MissionTimer, source, true ) end addEvent("setMissionTimer", true) addEventHandler("setMissionTimer", getLocalPlayer(), setTimer) function freeFromJail() destroyElement(MissionTimer) setElementPosition ( source, 264.74, 77.69, 1001.03 ) setElementInterior ( source, 0 ) setElementDimension ( source, 0 ) toggleControl(source, "fire", true) toggleControl(source, "next_weapon", true) toggleControl(source, "previous_weapon", true) toggleControl(source, "aim_weapon", true) toggleControl(source, "vehicle_fire", true) end addEventHandler ( "onClientMissionTimerElapsed", MissionTimer, freeFromJail) server: kreward = 150 function policeJob ( attacker, attackerweapon, bodypart, loss ) if attacker and getElementType(attacker) == "player" then theTeam = getPlayerTeam ( attacker ) local wlevel = getPlayerWantedLevel( source ) theSkin = getElementModel ( attacker ) if (attackerweapon == 3) and (loss > 2 ) and (wlevel > 0) then if getTeamName( theTeam ) == "Police Department" or getTeamName( theTeam ) == "Staff" or getTeamName( theTeam ) == "US Army" or getTeamName( theTeam ) == "US Marines" then setElementPosition ( source, 264.74, 77.69, 1001.03 ) setElementInterior ( source, 6 ) setElementDimension ( source, 3 ) toggleControl(source, "fire", false) toggleControl(source, "next_weapon", false) toggleControl(source, "previous_weapon", false) toggleControl(source, "aim_weapon", false) toggleControl(source, "vehicle_fire", false) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) outputChatBox ( "You have been jailed by "..theCop.. " for 5 minutes.", source ) outputChatBox ( "You have jailed "..theName, attacker ) local thisreward = wlevel*kreward givePlayerMoney ( attacker, thisreward ) setPlayerWantedLevel ( source, 0) triggerClientEvent("setMissionTimer", source) end end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) So this is correct? But I get error in debug, client.lua:19: bad argument @ addEventHandler [ expected element at argument 2, got nil. Not tested if it still works, but I will test.
  9. Adde

    missionTimer

    Okay so this should work: function freeFromJail() local time = getMissionTimerTime ( MissionTimer ) if ( time ) == 0 then destroyElement(MissionTimer) setElementPosition ( source, 264.74, 77.69, 1001.03 ) setElementInterior ( source, 0 ) setElementDimension ( source, 0 ) toggleControl(source, "fire", true) toggleControl(source, "next_weapon", true) toggleControl(source, "previous_weapon", true) toggleControl(source, "aim_weapon", true) toggleControl(source, "vehicle_fire", true) end end addEventHandler ( "onClientMissionTimerElapsed", MissionTimer, freeFromJail) Do you mean both functions or just freeFromJail?
  10. Adde

    missionTimer

    Hello. How do I set the missionTimer only visible to the jailed person? I am using "setElementVisibleTo" to make it visible for the jailed person, but then i have to hide it for the rest of the players. I don´t know how I should target the rest of the players... and btw, how can I finish the function "freeFromJail" and make it work? When I use setTimer(freeFromJail, 3000,1) the debug says "bad function at arg 1" or something. function policeJob ( attacker, attackerweapon, bodypart, loss ) if attacker and getElementType(attacker) == "player" then theTeam = getPlayerTeam ( attacker ) local wlevel = getPlayerWantedLevel( source ) theSkin = getElementModel ( attacker ) if (attackerweapon == 3) and (loss > 2 ) and (wlevel > 0) then if getTeamName( theTeam ) == "Police Department" or getTeamName( theTeam ) == "Staff" or getTeamName( theTeam ) == "US Army" or getTeamName( theTeam ) == "US Marines" then setElementPosition ( source, 264.74, 77.69, 1001.03 ) setElementInterior ( source, 6 ) setElementDimension ( source, 3 ) toggleControl(source, "fire", false) toggleControl(source, "next_weapon", false) toggleControl(source, "previous_weapon", false) toggleControl(source, "aim_weapon", false) toggleControl(source, "vehicle_fire", false) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) outputChatBox ( "You have been jailed by "..theCop.. " for 5 minutes.", source ) outputChatBox ( "You have jailed "..theName, attacker ) local thisreward = wlevel*kreward givePlayerMoney ( attacker, thisreward ) setPlayerWantedLevel ( source, 0) MissionTimer = exports.missionTimer:createMissionTimer ( 300000, true, "%m:%s" , 0.5, 0.5, true, "default-bold", 5, 255, 10, 10 ) setElementVisibleTo ( MissionTimer, source, true ) end end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) function freeFromJail() local time = getMissionTimerTime ( MissionTimer ) if ( time ) == 0 then destroyElement(MissionTimer) setElementPosition ( source, 264.74, 77.69, 1001.03 ) setElementInterior ( source, 0 ) setElementDimension ( source, 0 ) toggleControl(source, "fire", true) toggleControl(source, "next_weapon", true) toggleControl(source, "previous_weapon", true) toggleControl(source, "aim_weapon", true) toggleControl(source, "vehicle_fire", true) end end
  11. Thx it works, btw why wont cancelEvent() work instead of removePedFromVehicle? Nothing in debug. I found the reason, i changed onVehicleEnter to onVehicleStartEnter. vehicleSkins = { [425]=true, [520]=true, [432]=true } function onlyLevel15(thePlayer, seat, jacked) if tonumber(getElementData(thePlayer, "Level") ) <= 16 then if ( vehicleSkins[getElementModel(source)] ) then cancelEvent() outputChatBox("You need to be atleast level 15 to be able to use this vehicle",thePlayer, 255,0,0) end end end addEventHandler("onVehicleEnter", getRootElement(), onlyLevel15)
  12. Hey! Got a prob, I don´t understand what the debug means. Or I understand where the problem is but not how to solve it anyone that can help me? debug ( when entering the specified vehicle ) = server.lua4:attempt to compare string with number the script: vehicleSkins = { [425]=true, [520]=true, [432]=true } function onlyLevel15(thePlayer, seat, jacked) if ( getElementData(thePlayer, "Level") <= 16 ) then if ( vehicleSkins[getElementModel(source)] ) then removePedFromVehicle ( thePlayer ) outputChatBox("You need to be atleast level 15 to be able to use this vehicle",thePlayer, 255,0,0) end end end addEventHandler("onVehicleEnter", getRootElement(), onlyLevel15)
  13. Wops, didn´t see that. I got this far, open/close gui if player isn´t in acl group VIP and wrote some functions how I think that it should be and with no errors in debug. But no function will trigger. I know that I have guiGetText server side, I know that it´s wrong and make server wont work. But I can´t figure out any other solution. server function addToACL() local account = getplayerAccount(thePlayer) local accountName = getAccountName(thePlayer) local number = guiGetText(editBox1) local time = getRealTime() local date = time.monthday local endDate = date+number setAccountData(account, "aclRemove", endDate) aclGroupAddObject(aclGetGroup("VIP"), "user."..accountName) end addEvent("buyVIP", true) addEventHandler("buyVIP", getRootElement(), addToACL) function removeFromACLGroup() local account = getPlayerAccount(thePlayer) local accountName = getAccountName(account) local removeDate = getAccountData(account,"aclRemove") local time = getRealTime() local todayDate = time.monthday if ( removeDate ) == ( todayDate ) then aclGroupRemoveObject (aclGetGroup("VIP"), "user."..accountName) else return end end addEventHandler("onPlayerLogin", getRootElement(), removeFromACLGroup) function theGUIshow(thePlayer) local account = getPlayerAccount(thePlayer) local accName1 = getAccountName(account) if ( not isObjectInACLGroup ("user."..accName1, aclGetGroup ( "VIP" ) ) ) then triggerClientEvent(thePlayer,"show", thePlayer) end end function BindHere() bindKey(source, "F5", "down", theGUIshow) end addEventHandler("onPlayerLogin",getRootElement(),BindHere) client x, y = guiGetScreenSize() GUIEditor = { button = {}, window = {}, label = {}, edit = {} } VIPbuyPanel = guiCreateWindow(x*0.420, y*0.360, 228, 156, "VIP buy panel", false) guiWindowSetSizable(VIPbuyPanel, false) guiSetVisible(VIPbuyPanel, false) guiSetAlpha(VIPbuyPanel, 0.96) GUIEditoredit = guiCreateEdit(9, 31, 115, 36, "", false, VIPbuyPanel) GUIEditorbutton = guiCreateButton(134, 29, 85, 38, "Buy VIP", false, VIPbuyPanel) guiSetProperty(VIPbuyPanel, "NormalTextColour", "FFAAAAAA") GUIEditorlabel = guiCreateLabel(10, 79, 209, 21, "Enter how many VIP days you want", false, VIPbuyPanel) GUIEditorlabel = guiCreateLabel(10, 100, 55, 17, "VIP costs:", false, VIPbuyPanel) GUIEditorlabel = guiCreateLabel(69, 100, 78, 17, "N/A", false, VIPbuyPanel) GUIEditorlabel = guiCreateLabel(9, 124, 60, 18, "Total cost:", false, VIPbuyPanel) GUIEditorlabel = guiCreateLabel(75, 124, 78, 18, "", false, VIPbuyPanel) function onVIPPressBuy() local PlayerMoney = getPlayerMoney(getLocalPlayer()) local amount = guiGetText(GUIEditoredit) local theAmount = amount*30000 if ( PlayerMoney >= theAmount ) then if ( amount >= 1 ) then triggerServerEvent("buyVIP", source) guiSetVisible(VIPbuyPanel, false) showCursor(false) guiSetInputEnabled(false) else outputChatBox("You don´t have enough money for" ..amount.. "days of VIP", getLocalPlayer()) end end end addEventHandler("onClientGUIClick", GUIEditorbutton, onVIPPressBuy) function openGUIbuy() if guiGetVisible(VIPbuyPanel) then guiSetVisible(VIPbuyPanel, false) showCursor(false) guiSetInputEnabled(false) else guiSetVisible(VIPbuyPanel, true) showCursor(true) guiSetInputEnabled(true) end end addEvent("show",true) addEventHandler("show", getLocalPlayer(),openGUIbuy) Will something like this work?
  14. Thx! Okay ( quick example ) so If I have: local theDays = guiGetText ( editBox1 ) then I can do something like function vipShop(thePlayer) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(thePlayer) local time = getRealTime() local date = time.monthday if ( date = 1-1 ) and ( theDays = 10 ) then setAccountData(account, "1-11", VIPdate) aclGroupAddObject (aclGetGroup("VIP"), "user."..accountName)) end end end addEventhandler("onClientGUIClick", button1, vipShop) function checkRemoveDate(thePlayer) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(thePlayer) local time = getRealTime() local date = time.monthday getAccountData(account,"VIPdate") if ( VIPdate = 1-11 ) and ( date = 1-11 ) then aclGroupRemoveObject(aclGetGroup("VIP"), "user."..accountName) else return end end end addEventHandler("onPlayerLogin", getRootElement, checkRemoveDate) or can I do it on a easier way? like using set the remove date ( 1-1 + 10 )? I just remembered, "local theDays = guiGetText ( editBox1 )" i can´t use that in server side. Then i have to use triggerClientEvent right?
  15. Hello, I have a question about a system I am going to create that should count/remember days. Because I am going to create a script that adds a player to an acl group when he buys amount of days ingame for ingame money and then removes him x days later. And the question is, how can I do that? ( with counting days ). I am most thinking about if server restarts, the player leave, script restarts, etc and the script will still do exactly as it was told from the beginning/when player bought days. I hope that anyone can help me. Ask me more if you don´t understand what I mean.
  16. Adde

    Binds

    Thx, it works for me. So it should also work for Drakath.
  17. Adde

    Binds

    I have this problem to. It is really, really annoying. I think that it´s a bug in mta, because I didn´t have that problem in older verisions of mta.
  18. Na, didn´t make anything better. Same debug and no panel.
  19. Tried that before. Debug: Bad argument ´bindKey´.
  20. But I don´t know where I should place "bindKey" Okay, I changed that.
  21. Hello I have done a function that only makes people in acl group VIP available to write /vip and open the vip gui. I have tried different things but noone of them have worked. So, how do I add a bind that also only works for acl group VIP? server function theGUIshow(thePlayer) local account = getPlayerAccount(thePlayer) local accName1 = getAccountName(account) if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "VIP" ) ) then triggerClientEvent(thePlayer,"showTheGUI", thePlayer) else cancelEvent() end end addCommandHandler("vip",theGUIshow) client function openGUI() if guiGetVisible(GUIEditor.window[100]) == true then guiSetVisible(GUIEditor.window[100], false) showCursor(false) guiSetInputEnabled(false) else guiSetVisible(GUIEditor.window[100], true) showCursor(true) guiSetInputEnabled(true) end end addEvent("showTheGUI",true) addEventHandler("showTheGUI", getLocalPlayer(),openGUI)
  22. Oh, I haven´t noticed that function. But thank you
  23. Hey guys, I need some help with this script. It should make it unavailable for players in the same team ( police department ) to damage eachother IF the weapon isn´t oghtstick. I made it like this, can´t find the error. And nothing in debug. function noDM(attacker) if ( getPlayerTeam(source) == "Police Department" ) and ( getPlayerTeam(attacker) == "Police Department" ) and ( not getPlayerWeapon(attacker) == "3" ) then cancelEvent() end end addEventHandler("onPlayerDamage", getRootElement(), noDM)
  24. no, because getPlayerAccount, getAccountName, isObjectInACLGroup... it's avabile just in server side, you need to do a triggerClientEvent.. Oh, okay. Thanks for answearing
×
×
  • Create New...