Jump to content

Nameless

Members
  • Posts

    13
  • Joined

  • Last visited

Nameless's Achievements

Square

Square (6/54)

0

Reputation

  1. This doesnt check if someone pushed another player in the water right? Because that is what I need, I need to see who killed the other player --> pushed him in the water (who last touched him)
  2. Does somebody know if there is a killscript for Destruction Derby which I can download? I couldn't find it here: '>https://community.multitheftauto.com/index.php?p=resources Else if there are no downloads for a DD killscript could somebody tell me what's the best way of checking if a player has been killed by another player? And maybe give an example code? Thanks!
  3. Thank you very much Anderl!
  4. Hello, Can anybody tell me how to save the time played for a player? I need to start the time count when somebody logs in and stop the time count when he logs out or quits. (in a sqlite database) I hope you guys can help me! //Nameless
  5. Hi all, I fixed the problem: I deleted the returnAllStats function and put the triggerClientEvent(source, "showStats", getRootElement(), money, points, matches, first, second, third, kills) on the triggerEvent("returnallstats", getRootElement() , money, points, matches, firstplace, secondplace, thirdplace, kills ) his place. Now the 'source' is the player who opened the window or clicked the gridlist. Thanks for helping me! Cheers, Nameless
  6. Thanks for replying guys, but I really have no idea how to solve my problem..
  7. Ty for replying AeroXbird, but I didnt forgot the argument.
  8. Hi Guys, Nameless here again This time I got a problem with guiSetText. I am trying to create a userpanel with point, money, etc (with sqlite). All players who are online, will be set in a gridview. When a player opens the userpanel (F2) he will see his own stats. When the player clicks on another player in the gridview, the stats of the player he clicked on will show. My problem now is: When PlayerA presses F2, and PlayerB has his userpanel open. PlayerB will get to see PlayerA his stats. Also when PlayerA clicks on another player in the gridview PlayerB will see the stats of the player PlayerA clicked on. Here is my code: Clientside: local GUIWindow local playerGridView local playerColumn --stat labels local GUILabelMoney2 local GUILabelPoints2 local GUILabelMatches2 local GUILabelFirst2 local GUILabelSecond2 local GUILabelThird2 local GUILabelKills2 function createGUIWindow(test) local width, height = guiGetScreenSize () local windowW,windowH = 700,350 --Main Window sizes local windowX = (width/2) - (windowW/2) --Main Window horizontal position local windowY = (height/2) - (windowH/2) --Main Window vertical position --Window GUIWindow = guiCreateWindow (windowX, windowY, windowW, windowH, "Player Information Screen", false) --Tabpanel local GUITabPanel = guiCreateTabPanel ( 0 ,0.1, windowW, windowH, true, GUIWindow ) local GUITabStatistics = guiCreateTab ( "Statistics", GUITabPanel ) --Labels local GUILabelPlayerName = guiCreateLabel(0.02,0.06,0.94,0.2,"[PLAYER] his stats:",true,GUITabStatistics) local GUILabelMoney = guiCreateLabel(0.02,0.11,0.94,0.2,"Money:",true,GUITabStatistics) GUILabelMoney2 = guiCreateLabel(0.09,0.11,0.94,0.2,"",true,GUITabStatistics) local GUILabelPoints = guiCreateLabel(0.02,0.16,0.94,0.2,"Points:",true,GUITabStatistics) GUILabelPoints2 = guiCreateLabel(0.09,0.16,0.94,0.2,"",true,GUITabStatistics) local GUILabelPlayTime = guiCreateLabel(0.35,0.11,0.94,0.2,"Playtime:",true,GUITabStatistics) local GUILabelMatches = guiCreateLabel(0.02,0.30,0.94,0.2,"Mathes played:",true,GUITabStatistics) GUILabelMatches2 = guiCreateLabel(0.15,0.30,0.94,0.2,"",true,GUITabStatistics) local GUILabelFirst = guiCreateLabel(0.02,0.35,0.94,0.2,"1st Place:",true,GUITabStatistics) GUILabelFirst2 = guiCreateLabel(0.11,0.35,0.94,0.2,"",true,GUITabStatistics) local GUILabelSecond = guiCreateLabel(0.02,0.40,0.94,0.2,"2nd Place:",true,GUITabStatistics) GUILabelSecond2 = guiCreateLabel(0.11,0.40,0.94,0.2,"",true,GUITabStatistics) local GUILabelThird = guiCreateLabel(0.02,0.45,0.94,0.2,"3rd Place:",true,GUITabStatistics) GUILabelThird2 = guiCreateLabel(0.11,0.45,0.94,0.2,"",true,GUITabStatistics) local GUILabelKills = guiCreateLabel(0.02,0.50,0.94,0.2,"Kills:",true,GUITabStatistics) GUILabelKills2 = guiCreateLabel(0.075,0.50,0.94,0.2,"",true,GUITabStatistics) --Gridview playerGridView = guiCreateGridList ( 0.60, 0.10, 0.35, 0.85, true, GUITabStatistics ) --Create a players column in the list playerColumn = guiGridListAddColumn( playerGridView, "Player", 0.85 ) triggerEvent ( "refreshGridView", getRootElement() ) triggerServerEvent("getallstats", getRootElement()) --Set label colors: guiLabelSetColor ( GUILabelPlayerName, 255, 0, 0 ) --Set all label fonts: guiSetFont ( GUILabelPlayerName, "default-bold-small" ) guiSetFont ( GUILabelMoney, "default-bold-small" ) guiSetFont ( GUILabelPoints, "default-bold-small" ) guiSetFont ( GUILabelMatches, "default-bold-small" ) guiSetFont ( GUILabelFirst, "default-bold-small" ) guiSetFont ( GUILabelSecond, "default-bold-small" ) guiSetFont ( GUILabelThird, "default-bold-small" ) guiSetFont ( GUILabelPlayTime, "default-bold-small" ) guiSetFont ( GUILabelKills, "default-bold-small" ) addEventHandler ( "onClientGUIClick", playerGridView, updateStats, false ) guiSetVisible(GUIWindow, false) end addEventHandler("onClientResourceStart", getRootElement(),createGUIWindow) ------------------------------------------------------------------------------------------------------------ addEvent("refreshGridView", true) function refreshPlayerGrid() guiGridListClear ( playerGridView ) --clear gridview if ( playerColumn ) then --If the column has been created, fill it with players for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerGridView ) guiGridListSetItemText ( playerGridView, row, playerColumn, getPlayerName ( player ), false, false ) end end end addEventHandler("refreshGridView", getRootElement(), refreshPlayerGrid) addEventHandler ( "onClientPlayerChangeNick", getRootElement(), refreshPlayerGrid) ------------------------------------------------------------------------------------------------------------ function showWindow(thePlayer) -- function for trigger if (guiGetVisible(GUIWindow) == true) then -- if window opened then guiSetVisible (GUIWindow,false ) -- close window showCursor(false) --disable cursor guiSetInputEnabled(false) --disable input focus else guiSetVisible (GUIWindow,true )-- enable --//-- showCursor(true) -- enable --//-- guiSetInputEnabled(true) --enable --//-- --trigger all stats event triggerServerEvent("getallstats",getRootElement(),thePlayer) end end addEvent( "showWdw", true ) addEventHandler( "showWdw", getRootElement(), showWindow ) ------------------------------------------------------------------------------------------------------------ function showStats(money, points, matches, first, second, third, kills) guiSetText ( GUILabelMoney2, money ) guiSetText ( GUILabelPoints2, points ) guiSetText ( GUILabelMatches2, matches ) guiSetText ( GUILabelFirst2, first ) guiSetText ( GUILabelSecond2, second ) guiSetText ( GUILabelThird2, third ) guiSetText ( GUILabelKills2, kills ) end addEvent( "showStats", true ) addEventHandler( "showStats", getRootElement(), showStats ) ------------------------------------------------------------------------------------------------------------ function updateStats() local playerName = guiGridListGetItemText ( playerGridView, guiGridListGetSelectedItem ( playerGridView ), 1 ) if(playerName ~= false and playerName ~= nil and playerName ~= "") then triggerServerEvent("getallstats",getRootElement(),getPlayerFromName(playerName)) end end ------------------------------------------------------------------------------------------------------------ Serverside: function refreshPlayerGrid() triggerClientEvent("refreshGridView", getRootElement()) end addEventHandler("onPlayerJoin", getRootElement(), refreshPlayerGrid) addEventHandler ( "onPlayerQuit", getRootElement(), refreshPlayerGrid) ------------------------------------------------------------------------------------------------------------ function getAllStats(thePlayer) local accountname = getAccountName (getPlayerAccount (thePlayer )) local money local points local matches local firstplace local secondplace local thirdplace local kills if( accountname ~= nil and accountname ~= false and accountname ~= "guest")then local statsConnection = dbConnect( "sqlite", "statistics.db" ) if(statsConnection)then local statsQuery = dbQuery ( statsConnection , "SELECT * FROM accountdata WHERE playername = ?" , accountname ) if(statsQuery)then local statsResults = dbPoll ( statsQuery , -1 ) if(statsResults ~= false and statsResults ~= nil) then for statsResults, row in pairs ( statsResults ) do --get all results from given player (thePlayer) money = ( row["money"]) points = ( row["points"]) matches = ( row["matches"]) firstplace = ( row["firstplace"]) secondplace = ( row["secondplace"]) thirdplace = ( row["thirdplace"]) kills = ( row["kills"]) end--end for loop triggerEvent("returnallstats", getRootElement() , money, points, matches, firstplace, secondplace, thirdplace, kills ) end --end statsResults end--end statsQuery end--end statsconnection end--end accountname end--end getAllStatsFunction addEvent("getallstats", true) addEventHandler("getallstats", getRootElement(), getAllStats) ------------------------------------------------------------------------------------------------------------ function returnAllStats(money, points, matches, first, second, third, kills) triggerClientEvent(source, "showStats", getRootElement(), money, points, matches, first, second, third, kills) end addEvent("returnallstats", true) addEventHandler("returnallstats",getRootElement(), returnAllStats) ------------------------------------------------------------------------------------------------------------ --BINDKEYS addEventHandler("onPlayerLogin", getRootElement(), function() bindKey(source, "F2", "down", function(player, key, state) triggerClientEvent(player,"showWdw", getRootElement(), player) end) end ) addEventHandler("onPlayerLogout", getRootElement(), function() unbindKey(source, "F2") end ) ------------------------------------------------------------------------------------------------------------ I hope you guys can help me with this problem! I am a beginning scripter, so if you have any other suggestions please feel free to post! Cheers, Nameless
  9. Thank you all for helping me with my problem! The client script wasn't working because there was a -- missing for a comment
  10. The script only executes server scripts.. but not the client ones
  11. Thanks for your reply, but I dont want to show the window to everybody! I want it to show to the admin who pressed F10
  12. ChangetriggerClientEvent("showMsgWdw", getRootElement()) to triggerClientEvent(player,"showMsgWdw", getRootElement()) What do you mean? Thank you for your reply! I changed the triggerClientEvent, but the window doesnt show up anymore.. For some reason the showMessageWindow function is not executed.
  13. Hi, I have a problem with showing my GUI window; -- How do I give the status (true or false) to set the window visible? -- If I press "F10" (as an admin the window gets visible for everybody Is there a way I can fix this? If you dont understand my problem, please ask! Here is my code: --Server script, checking if logged in player is admin local root = getRootElement() addEventHandler("onPlayerLogin", root, function() if ( hasObjectPermissionTo ( source, "function.aclSetRight", false ) ) then bindKey(source, "F10", "down", function(player, key, state) triggerClientEvent("showMsgWdw", getRootElement()) end) end end ) --Client script to set window visible function showMessageWindow(status) --check if function should show or hide window if status ~= true and status ~= false then status = not guiGetVisible(msgWindow) end if status == true then guiSetInputEnabled(true) guiSetVisible(msgWindow, true) showCursor(true) else guiSetInputEnabled(false) guiSetVisible(msgWindow, false) showCursor(false) end end addEvent( "showMsgWdw", true ) addEventHandler( "showMsgWdw", getRootElement(), showMessageWindow ) I really hope you guys can find a sollution for my problem!
×
×
  • Create New...