Jump to content

steadyfi

Members
  • Posts

    144
  • Joined

  • Last visited

Everything posted by steadyfi

  1. What do you mean ? I think dxDrawText works with all of them
  2. I think he want's to draw the money with PLN in front (I think it's Poland's Currency) Simple Script: (Client-Side) addEventHandler("onClientRender", function() dxDrawText("PLN "..getPlayerMoney(getLocalPlayer()), 200, 200) end) addEventHandler("onResourceStart", function() setPlayerHudComponentVisible(getLocalPlayer(), "money", false) end) Functions Used: dxDrawText: https://wiki.multitheftauto.com/wiki/DxDrawText getPlayerMoney: https://wiki.multitheftauto.com/wiki/GetPlayerMoney setPlayerHudComponentVisible: https://wiki.multitheftauto.com/wiki/Se ... entVisible I haven't tested it, but it should work.
  3. steadyfi

    Vehicle weapon

    Read the wiki. Wiki: https://wiki.multitheftauto.com/ Collision Shapes (Client): https://wiki.multitheftauto.com/wiki/Cl ... _functions Collision Shapes (Server): https://wiki.multitheftauto.com/wiki/Se ... _functions Functions you need: Collision Spheres: https://wiki.multitheftauto.com/wiki/CreateColSphere isElementWithinColShape: https://wiki.multitheftauto.com/wiki/Is ... inColShape SetElementPosition: https://wiki.multitheftauto.com/wiki/SetElementPosition SetElementData: https://wiki.multitheftauto.com/wiki/SetElementPosition SetElementFrozen: https://wiki.multitheftauto.com/wiki/SetElementFrozen AttachElements: https://wiki.multitheftauto.com/wiki/AttachElements (MAYBE, I'M NOT SURE) SetElementSyncer: https://wiki.multitheftauto.com/wiki/SetElementSyncer BindKey: https://wiki.multitheftauto.com/wiki/BindKey ^^ These are some of them, i'm not gonna list all of them ^^ You also got some functions by others. Combine them with what you got, and see what it turns out to be.
  4. steadyfi

    Vehicle weapon

    To change the state of firing replace "firing" to "ready" https://wiki.multitheftauto.com/wiki/SetWeaponState
  5. Ok, but it now duplicates everytime I run the function. The gridlist doesn't get cleared EDIT: Nevermind, I just added the table in my gui function so everytime when I open it the table gets reseted
  6. Client-Side: local playerTable = {} addEvent("openteams.getPlayersFromAccounts.serverGave", true) addEventHandler("openteams.getPlayersFromAccounts.serverGave", getRootElement(), function(pName) guiGridListClear(teamPlayersGrid) table.insert(playerTable, {pName}) for index, player in ipairs(playerTable) do local row = guiGridListAddRow(teamPlayersGrid) guiGridListSetItemText(teamPlayersGrid, row, 1, player[index], false, false) getPlayerRow[player] = row end end) The getPlayerRow = {} is also added, it's just not in this part of the file Server-Side: addEvent("openteams.getPlayersFromAccounts", true) addEventHandler("openteams.getPlayersFromAccounts", getRootElement(), function() local team = getPlayerTeam(source) if team then --CODE local allAccounts = getAccounts() for _, account in ipairs(getAccounts()) do if getTeamName(team) == getAccountData(account, "openteams.team.name") then local playerName = getAccountData(account, "openteams.account.name") triggerClientEvent(source, "openteams.getPlayersFromAccounts.serverGave", source, playerName) end end --END CODE end end)
  7. It's working, but it still gives me an error: expected string at argument 4, got nil
  8. I didnt see that, my wrong. Still getting an error
  9. I kinda imagine what you are talking about but i'm not sure. Could you please make it for me ? Like i said, it's the first time I use tables so I don't know anything about them.
  10. Didn't work. Error:
  11. Oh, sorry. I completely forgot. Error: ERROR: openteams/client.lua:243: table index is nil
  12. Hello I have a little problem. It's my first time when I use tables and I wonder how can I make my script work. This is what I do: 1. I loop through all of the accounts 2. Find the ones with the account data equal to what I need 3. Get the players name what is also stored as account data 4. Use table.insert to insert it into the table (then loop again from 1 until there is nothing left) 5. And pass the table Client-Side where I need it Client-Side Script: addEvent("openteams.getPlayersFromAccounts.serverGave", true) addEventHandler("openteams.getPlayersFromAccounts.serverGave", getRootElement(), function(playerTable) guiGridListClear(teamPlayersGrid) for index, player in ipairs(playerTable) do local row = guiGridListAddRow(teamPlayersGrid) guiGridListSetItemText(teamPlayersGrid, row, 1, player, false, false) getPlayerRow[players] = row end end) I also have a trigger: (Client-Side too) triggerServerEvent("openteams.getPlayersFromAccounts", localPlayer) Server-Side Script: addEvent("openteams.getPlayersFromAccounts", true) addEventHandler("openteams.getPlayersFromAccounts", getRootElement(), function() local team = getPlayerTeam(source) if team then --CODE local playerTable = {} local allAccounts = getAccounts() for _, account in ipairs(getAccounts()) do if getTeamName(team) == getAccountData(account, "openteams.team.name") then local playerName = getAccountData(account, "openteams.account.name") table.insert(playerTable, playerName) end end --END CODE triggerClientEvent(source, "openteams.getPlayersFromAccounts.serverGave", source, playerTable) end end) Hope you understand what I want to do, i tried my best to explain. Thank you
  13. Hello. I'm wondering if I could trigger a event with triggerClientEvent() just for one player. I'm sending localPlayer to the server and how can I send it back to him ? I already tried this: triggerClientEvent("openteams.getPlayerPermissionLevel.serverGave", source, playerRank) Note: Yes, the event is added client-side Thanks
  14. Also, 1. Security isn't important, all I do is passing localPlayer Server-Side, getting a string, and passing it back Client-Side 2. It now says an event is not triggerable. Client Side: local localPlayer = getLocalPlayer() function teamSetText() team = getPlayerTeam(getLocalPlayer()) if team then guiSetText(teamNameLabel, "Team: "..getTeamName(getPlayerTeam(getLocalPlayer()))) guiSetText(playerCountLabel, "Players: "..countPlayersInTeam(getPlayerTeam(getLocalPlayer()))) triggerServerEvent("openteams.getTeamLeader", localPlayer) end end function serverGaveLeaderName(leaderName) team = getPlayerTeam(getLocalPlayer()) if team then guiSetText(teamNameLabel, "Leader: "..tostring(leaderName)) end end addEvent("openteams.getTeamLeader.serverGave") addEventHandler("openteams.getTeamLeader.serverGave", getRootElement(), serverGaveLeaderName) Server-Side: function giveClientLeaderName() local team = getPlayerTeam(source) if team then --XML local xmlFile = xmlLoadFile("teams.xml", "root") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attribute = xmlNodeGetAttribute(node, "name") if attribute == getTeamName(team) then local leaderName = xmlNodeGetAttribute(node, "leader") end end xmlUnloadFile(xmlFile) --END XML triggerClientEvent("openteams.getTeamLeader.serverGave", root, leaderName) end end addEvent("openteams.getTeamLeader", true) addEventHandler("openteams.getTeamLeader", getRootElement(), giveClientLeaderName) Error: Server triggered clientside event openteams.getLeaderName.serverGave, but event is not marked as remotly triggerable
  15. Thank you. By the way, could you give me the link to the wiki page ?
  16. Hi. I have a little problem with passing the localPlayer variable from Client-Side to Server-Side with a triggerServerEvent() Client-Side Code: local localPlayer = getLocalPlayer() function teamSetText() team = getPlayerTeam(getLocalPlayer()) if team then guiSetText(teamNameLabel, "Team: "..getTeamName(getPlayerTeam(getLocalPlayer()))) guiSetText(playerCountLabel, "Players: "..countPlayersInTeam(getPlayerTeam(getLocalPlayer()))) triggerServerEvent("openteams.getTeamLeader", localPlayer) end end Server-Side Code: function giveClientLeaderName(localPlayer) local team = getPlayerTeam(localPlayer) if team then --XML local xmlFile = xmlLoadFile("teams.xml", "root") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attribute = xmlNodeGetAttribute(node, "name") if attribute == getTeamName(team) then local leaderName = xmlNodeGetAttribute(team, "leader") end end xmlUnloadFile(xmlFile) --END XML triggerClientEvent("openteams.getTeamLeader.serverGave", leaderName) end end addEvent("openteams.getTeamLeader", true) addEventHandler("openteams.getTeamLeader", getRootElement(), giveClientLeaderName) Error: It says it expected the player element but it got nil (it wasn't passed)
  17. I think you can set a security number generated randomly and just print it when the account is created. Then make a script to check for the node with the account name = to the account name in the xml and if Key = Key in XML then you just use: setAccountPassword in a script I think i'm gonna make one. Sound's intresting, i will do one to. Just keep in mind that you have to place it in your login script because there is no event for creating accounts
  18. I think you can set a security number generated randomly and just print it when the account is created. Then make a script to check for the node with the account name = to the account name in the xml and if Key = Key in XML then you just use: setAccountPassword in a script I think i'm gonna make one.
  19. Thank you, I will test it later because I have a bit of work right now. #SOLVED i hope
  20. Didn't work. Server-Side: --##DEVELOPMENT CODE for id, playerAbc in ipairs(getElementsByType("player")) do thePlayersAccount = getPlayerAccount(playerAbc) setAccountData(thePlayersAccount, "isTeamAdmin", false) setAccountData(thePlayersAccount, "isTeamLeader", false) setAccountData(thePlayersAccount, "invited_to_team", false) setAccountData(thePlayersAccount, "team_invited_to", false) end --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x-- function getPlayerFromPartialName(who) --Useful Function | Author: TAPL local who = who and who:gsub("#%x%x%x%x%x%x", ""):lower() or nil if who then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(who, 1, true) then return player end end end end --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x-- function createATeam(source, commandName, teamName) local team = getPlayerTeam(source) if team then outputChatBox("You are already in a team", source, 255, 0, 0) return end if teamName then --Check if team already exists local xmlFile = xmlLoadFile("teams.xml", "root") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attribute = xmlNodeGetAttribute(node, "name") if attribute == teamName then outputChatBox("This team already exists", source, 255, 0 ,0) return end end xmlUnloadFile(xmlFile) --END local newTeam = createTeam(teamName) if newTeam then setPlayerTeam(source, newTeam) local playerAccount = getPlayerAccount(source) setAccountData(playerAccount, "isTeamLeader", true) --XML local xmlFile = xmlLoadFile("teams.xml", "root") local team = xmlCreateChild(xmlFile, "team") local success = xmlNodeSetAttribute(team, "name", teamName) if success then xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end --END XML outputChatBox("Successfully created team with name: "..teamName, source, 0, 255, 0) triggerEvent("setBlip", root) else outputChatBox("An error accrued while creating the team", source, 255, 0, 0) end else outputChatBox("Please enter a team name", thePlayer, 255, 0, 0) end end addCommandHandler("create", createATeam) function inviteToTeam(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true then local target = getPlayerFromPartialName(who) if target then if target ~= thePlayer then if not getElementData(target, "invited_to_team") then local teamName = getTeamName(team) setElementData(target, "invited_to_team", true) setElementData(target, "team_invited_to", teamName) outputChatBox("Invited player "..getPlayerName(target).." to team !", thePlayer, 0, 255, 0) outputChatBox("You were invited to the team: "..teamName.." !", target, 0, 255, 0) outputChatBox("Type '/team accept' or '/team deny'", target, 0, 255, 0) elseif getElementData(target, "invited_to_team") then outputChatBox("The player is already invited to a team", thePlayer, 255, 0, 0) return end else outputChatBox("You cannot invite yourself", thePlayer, 255, 0, 0) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access forbidden", thePlayer, 255, 0, 0) end else outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("invite", inviteToTeam) function inviteHandling(thePlayer, cmd, arg) if arg then if getElementData(thePlayer, "invited_to_team") == true then if arg == "accept" then local team = getPlayerTeam(thePlayer) if not (team) then local theTeam = getTeamFromName(getElementData(thePlayer, "team_invited_to")) local playerName = getPlayerName(thePlayer) local teamPlayers = getPlayersInTeam(theTeam) setPlayerTeam(thePlayer, theTeam) outputChatBox("Joined team "..getTeamName(theTeam), thePlayer, 0, 255, 0) for playerKey, playerValue in ipairs(teamPlayers) do outputChatBox(playerName.." joined the team !", playerValue, 0, 255, 0) end setElementData(thePlayer, "invited_to_team", false) triggerEvent("setBlip", root) elseif team then outputChatBox("You are already in a team ! Leave it before joining another.", thePlayer, 255, 0, 0) end elseif arg == "deny" then local playerName = getPlayerName(thePlayer) setElementData(thePlayer, "invited_to_team", false) setElementData(thePlayer, "team_invited_to", false) --outputChatBox(playerName.." has declined the invitation !", inviter, 255, 0, 0) outputChatBox("Invitation declined", thePlayer, 0, 255, 0) end else outputChatBox("You are not invited to any team", thePlayer, 255, 0, 0) end else outputChatBox("Argument 2 is missing. arg2 = accept/deny", thePlayer, 255, 0, 0) end end addCommandHandler("team", inviteHandling) function permitAPlayer(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true then target = getPlayerFromPartialName(who) if target then local targetAccount = getPlayerAccount(target) if not getAccountData(targetAccount, "isTeamLeader") then if target ~= thePlayer then if getPlayerTeam(target) == team then if not getAccountData(targetAccount, "isTeamAdmin") then setAccountData(targetAccount, "isTeamAdmin", true) local targetPlayerName = getPlayerName(target) outputChatBox(targetPlayerName.." added as admin !", thePlayer, 0, 255, 0) local teamName = getTeamName(team) outputChatBox("You were added as a admin in team: "..teamName.." !", target, 0, 255, 0) elseif getAccountData(targetAccount, "isTeamAdmin") then setAccountData(targetAccount, "isTeamAdmin", false) local targetPlayerName = getPlayerName(target) outputChatBox(targetPlayerName.." removed as admin !", thePlayer, 0, 255, 0) local teamName = getTeamName(team) outputChatBox("You were removed as a admin in team: "..teamName.." !", target, 0, 255, 0) end else outputChatBox("Player not in team", thePlayer, 255, 0, 0) end else outputChatBox("You cannot permit yourself", thePlayer, 255, 0, 0) end else outputChatBox("You cannot permit a leader", thePlayer) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access Forbidden", thePlayer, 255, 0, 0) end elseif not (team) then outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("permit", permitAPlayer) function kickFromTeam(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true or getAccountData(playerAccount, "isTeamAdmin") == true then target = getPlayerFromPartialName(who) if target then if target ~= thePlayer then if getPlayerTeam(target) == team then local targetAccount = getPlayerAccount(target) if not getAccountData(targetAccount, "isTeamLeader") then setPlayerTeam(target, nil) local targetPlayerName = getPlayerName(target) outputChatBox("Kicked "..targetPlayerName.." from team !", thePlayer, 0, 255, 00) outputChatBox("You were kicked from the team ! D:", target, 255, 0, 0) triggerEvent("setBlip", root) else outputChatBox("You cannot kick the leader !", thePlayer) end else outputChatBox("Player not in team", thePlayer, 255, 0, 0) end else outputChatBox("You cannot kick yourself", thePlayer, 255, 0, 0) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access Forbidden", thePlayer, 255, 0, 0) end elseif not (team) then outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("tkick", kickFromTeam) function leaveTeam(thePlayer) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if not getAccountData(playerAccount, "isTeamLeader") then if getAccountData(playerAccount, "isTeamAdmin") then setAccountData(playerAccount, "isTeamAdmin", false) end setPlayerTeam(thePlayer, nil) local teamName = getTeamName(team) outputChatBox("You left the team "..teamName.." !", thePlayer, 0, 255, 0) local teamPlayers = getPlayersInTeam(team) local playerName = getPlayerName(thePlayer) for playerKey, playerValue in ipairs(teamPlayers) do outputChatBox(playerName.." left the team ! D:", playerValue, 255, 0, 0) end triggerEvent("setBlip", root) else outputChatBox("You can not leave as a leader", thePlayer, 255, 0, 0) end elseif not (team) then outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("leave", leaveTeam) function deleteTeam(thePlayer) local team = getPlayerTeam(thePlayer) if
×
×
  • Create New...