-
Posts
1,803 -
Joined
-
Last visited
-
Days Won
8
Everything posted by Citizen
-
And if you mean't the last value in a table: local value = myTable[ #myTable ]
-
Humm yeah, thought he wanted to get the ammo in clips too. Btw I knew that getPedTotalAmmo includes clip. Because I think he probably wants to do a custom HUD.
-
You just changed the encoding type of the communications between your script and the sql server to UTF-8 for the current connection (theMysql). Because ASCII encoding can't handle your special characters.
-
Np, in my code, the if ( data [ 1 ].password == password ) then is done by the sql server that will process the query. If the password is wrong, then the sql server will returns no result. And be carefull with big requests. Use a callback to prevent the possible freeze of your server.
-
and:getPedAmmoInClip
-
Hahaha, sorry but were you drunk when you made this ? dbQuery(connect, "SELECT username password FROM accounts") Doesn't returns an account at all. It returns a query handler to be used in dbPoll then local qh = dbQuery(connect, "SELECT * FROM accounts WHERE username='?' AND password='?'", username, password) local result = dbPoll( qh, -1 ) if result and #result == 1 then --Good login and password since the query returned a result local datas = result[1] --datas is a table with all columns of the accounts table (but only with the datas of the player) -- datas.username contains the username in the database else -- Wrong login and/or password end Using dbPoll without a callback like I just did will freeze the server untill we got the table result (invisible on small queries). EDIT: Damn it ! I should write faster ! I'm late again
-
Come on slaves ! We can help this nice gentleman ! Haha, you are really funny. You made my day thanks
-
You're welcome. I really suggest you to keep your resource as a regular folder (not as a zip) while coding it.
-
You probably meant math.random or you should link the utility function: https://wiki.multitheftauto.com/wiki/Table.random
-
Sure: local screenW, screenH = guiGetScreenSize() addEventHandler("onClientResourceStart", resourceRoot, function () for k, player in ipairs (getElementsByType("player")) do setPlayerNametagShowing(player, false) end end) function drawMyName() local myName = getPlayerName(localPlayer) local x, y = screenW/2, screenH/2 dxDrawText(tostring(myName), x, y) end addEventHandler("onClientRender", root, drawMyName)
-
You don't want to use other resources but you can't do it yourself either even after we told you the main idea and the functions you would have to use. Learn to script simple stuff first. Check the Introduction to Scripting available on the wiki main page. function createGang( thePlayer, cmd, gngName ) if not thePlayer or not cmd then return end if not gngName then return outputChatBox("SYNTAX: /createGang ") end if getElementData(thePlayer, "gang") then return outputChatBox("You are already in a gang. Do /leaveGang to leave it.", thePlayer) end if isGangAlreadyExist(gngName) then return outputChatBox("The gang "..gngName.." already exist !", thePlayer) end local newGang = createElement("gang") setElementData(newGang, "name", gngName) setElementData(newGang, "leader", gngName) setElementData(newGang, "members", {}) outputChatBox("You successfully created the "..gngName.." gang and you are the leader !", thePlayer) end addCommandHandler("createGang", createGang, false, false) function inviteInGang( thePlayer, cmd, playerName ) if not thePlayer or not cmd then return end if not playerName then return outputChatBox("SYNTAX: /invite ", thePlayer) end local gang = getElementData(thePlayer, "gang") if not gang then return outputChatBox("You must be part of a gang first. Do /createGang to create your own.", thePlayer) end local newMember = getPlayerFromName(playerName) if not newMember then return outputChatBox("Player "..playerName.." not found !", thePlayer) end if newMember == thePlayer then return outputChatBox("You can't invite your self into a gang !", thePlayer) if getElementData(newMember, "gang") then return outputChatBox("The player "..playerName.." is already in a gang. Ask him to leave first.", thePlayer) end if addNewMemberToGang(gang, newMember) then local gangName = getElementData(gang, "name") or "" outputChatBox("Congrats ! You are now part of the "..tostring(gangName).." gang !", newMember) outputChatBox(playerName.." is now a member of your gang !", thePlayer) else outputChatBox("An error has occured. Please contact an administrator.", thePlayer) end end addCommandHandler("invite", inviteInGang, false, false) function leaveGang( thePlayer ) if not thePlayer then return end local gang = getElementData(thePlayer, "gang") if not gang then return outputChatBox("You already aren't in a gang !", thePlayer) end if removeMemberFromGang( gang, thePlayer ) then local gangName = getElementData(gang, "name") or "" local leader = getElementData(gang, "leader") outputChatBox("You successfully left the "..tostring(gangName).." gang !", thePlayer) if leader and isElement(leader) then outputChatBox(playerName.." left your gang !", leader) end else outputChatBox("An error has occured. Please contact an administrator.", thePlayer) end end addCommandHandler("leaveGang", leaveGang, false, false) function addNewMemberToGang( theGang, thePlayer ) if not theGang or not thePlayer then return end local members = getElementData(theGang, "members") table.insert(members, thePlayer) return (setElementData(newMember, "gang", theGang) and setElementData(theGang "members", members)) end function removeMemberFromGang( theGang, thePlayer ) if not theGang or nor thePlayer then return end local tmp = getElementData(theGang, "members") or {} local members = {} for k, member in ipairs(members) do if member ~= thePlayer then table.insert(members, member) end end return (removeElementData(thePlayer, "gang") and setElementData(theGang, "members", members)) end function isGangAlreadyExist( gngName ) for k, theGang in ipairs (getElementsByType("gang")) do local name = getElementData(theGang, "name") or "" if name == gngName then return true end end return false end function gangChat ( thePlayer, _, ... ) local text = table.concat ( { ... }, " " ) local theGang = getElementData(thePlayer, "gang") if #text == 0 or not theGang then return end local members = getElementData(theGang, "members") or {} local playerName = getPlayerName(thePlayer) for k, member in ipairs (members) do outputChatBox ("#FF32AA (GANG) "..playerName..": #FFFFFF"..text, member, 255, 255, 255, true ) end end addCommandHandler ( "gangChat", gangChat ) addCommandHandler ( "gc", gangChat ) This script may have bugs since I didn't test it.
-
NO ! playSound is the function you wanted to use. playSound3D is to play a sound at a specific location in the GTA world like sound engines for example, or explosions. The function yourFunc() must be called when the players join the server (so when the client resource start). You had to remove ... in the function, if not, then you are dumb (sorry, but it would be the truth) The function playerSelected must be an handler of onClientGUIClick for the button or character's image. Show us the whole client side script.
-
Server: --Server function onPlayerKilled( killer ) triggerClientEvent("onPlayerKilled", source, killer ) end addEventHandler("onPlayerWasted", root, onPlayerKilled) Client: -- Client local screen_width, screen_height = guiGetScreenSize() local killMsgQueue = {} local killTimeDisplay = 5000 --5 secs addEvent("onPlayerKilled", true) function addKillEntry( killer ) if not source or not killer or not killMsgQueue then return end local msg = tostring(getPlayerName(source)).." has been killed by "..tostring(getPlayerName(killer)) table.insert(killMsgQueue, msg) end addEventHandler("onPlayerKilled", root, addKillEntry) function popFirst() local tmp, killMsgQueue = killMsgQueue, {} for k, i in ipairs(tmp) do if k > 1 then table.insert(killMsgQueue, i) end end end local tick, currentMsgTime = getTickCount(), 0 function renderDisplay( ) if not killMsgQueue or #killMsgQueue == 0 then return end currentMsgTime = currentMsgTime + getTickCount() - tick tick = getTickCount() if currentMsgTime <= killTimeDisplay then local msg = killMsgQueue[1] local text_width, text_height = dxGetTextWidth( msg ), dxGetFontHeight() dxDrawRectangle( ( screen_width - text_width ) / 2 - 15, ( screen_height - text_height ) / 2 - 15, text_width + 30, text_height + 30, tocolor( 0, 0, 0, 200 ) ) dxDrawText( msg, ( screen_width - text_width ) / 2, ( screen_height - text_height ) / 2, ( screen_width - text_width ) / 2 + text_width, ( screen_height - text_height ) / 2 + text_height, tocolor( 255, 255, 255, 255 ) ) else popFirst() currentMsgTime = 0 end end
-
A gang chat is not the same as PM because PM is between two players only (at least for me). You have to do another command first to create the gang/group and then you will invite other players in it. If you don't want to let anyone be able to create a gang/group (then definied by the script), you will have to create the group 1st and then you need to put AT LEAST one guy into it (usually the leader). In your case, the player1 who is not in a gang/group is inviting player2 in a gang he doesn't own.
-
First you can remove this: setSoundVolume(sound, 100) -- The volume range is 0.0 to 1.0 (= 100%) and it's already 1.0 by default) setSoundMaxDistance(sound, 100) -- not needed because it's not a 3D sound setElementDimension(sound, 0) -- not a 3D sound too Then do something like this: local welcomeSound function yourFunc() ... welcomeSound = playSound("login.mp3", true) ... end --Call the following function with "onClientGUIClick" event function playerSelected( button ) if button == "left" then -- get the caracter stopSound( welcomeSound ) --stop the sound -- trigger the server here and give the caracter he selected and do your spawn process on severside end end
-
1 - The binds wont work if players join after the resource as beed started. 2 - The script will still not work because you don't send v as argument.
-
You should defintly check this: Introduction to Scripting function openhelpacs(player) if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("TT"))) then triggerClientEvent(player, "openhelp", root) end end -- When the resource starts, bind the key for everyone that are already on the server function resourceStart () for k, p in ipairs (getElementsByType("player")) do bindKey(p, "F3", "down", openhelpacs, p) end end addEventHandler ("onResourceStart", resourceRoot, resourceStart) -- When a new player join, bind the key for him function playerJoins() bindKey(source, "F3", "down", openhelpacs, source) end addEventHandler("onPlayerJoin", root, playerJoins)
-
I read the function but i dint need a postion coordinates It's just some maths, you can give the starting gradient and the ending one (of course you need to use 2 interpolate between since you have 6 values to fade nicely). The function doesn't care if the values you are giving will be then used for sky gradient or to set the position of an object or a gui/dx element. They are just numbers. That function will just go from the start numbers to the ending ones using the easing function you want.
-
Yes of course, excepted if you are using the element data "invited" like who am I did.
-
The error is not complete. I just checked the source code of MTA and here is the only similar string I found: m_strFailureReason = SString ( "Couldn't find resource archive or directory (%s) for resource '%s'.\n", m_strResourceDirectoryPath.c_str (), m_strResourceName.c_str () ); - Your archive isn't a zip file or uses an unknown compression or has a password. - Your archive file contains weird characters (don't use russian or polish caracters). While developping a mod/script, there is no need for your resource to be a zip file, you can use folders instead: - Go in your resources folder then create a folder myscript and put your meta.xml and Main.lua in it. - Start the server and try to start your resource. By keeping your resource as a regular folder, you can develop 5 times (totally a random number yeah ) faster because you don't need to update your zip file.
-
It wasn't my choice, that was how this script was initially made. Didn't want him to think he couldn't do that with dx functions.
-
Will only work for one group chat and you will have to invite the guys each time they reconnect. I would use element datas to know in which group the guy is and persist the data in database (Mysql or account datas). The invite command will check in which group the player who wrote the cmd is and then add the target player to that group. Then the chat will display group messages between guys that are in the same group.
-
Or just set the postGUI argument to true ... -- SELECTION DRAW -- -- IMAGES -- --EXAMPLE -- -- bool dxDrawImage ( float posX, float posY, float width, float height, mixed image [, float rotation = 0, float rotationCenterOffsetX = 0, float rotationCenterOffsetY = 0, int color = tocolor(255,255,255), bool postGUI = false ] ) -- local sx, sy = guiGetScreenSize() dxDrawImage(sx/2-(275/599*sx), sy/2-(200/576*sy), 309/1600*sx, 174/900*sy, "data/img/selection_forest.jpg", 0, 0, 0, tocolor(255, 255, 255, alpha_selection["forest"]), true) dxDrawImage(sx/2-(275/599*sx), sy/2-(80/900*sy), 309/1600*sx, 174/900*sy, "data/img/selection_industry.jpg", 0, 0, 0, tocolor(255, 255, 255, alpha_selection["industry"]), true) --dxDrawImage(sx/2-(275/1600*sx), sy/2-(-40/900*sy), 501/1600*sx, 103/900*sy, "data/img/selection_forest.jpg", 0, 0, 0, tocolor(255, 255, 255, alpha_selection["forestas"]), true)-- dxDrawImage(sx/2-(275/599*sx), sy/2-(-170/900*sy), 309/1600*sx, 174/900*sy, "data/img/selection_forest.jpg", 0, 0, 0, tocolor(255, 255, 255, alpha_selection["forestass"]), true) -- TEXT -- local scale = 0.5/1600*sx dxDrawText("CHOOSE A MAP", sx/2-(200/1600*sx), sy/2-(300/900*sy), sx/2, sy/2, tocolor(255, 255, 255), scale, slender_font, "left", "top", false, false, true) scale = 0.3/1600*sx dxDrawText("FOREST", sx/2-(270/1600*sx), sy/2-(125/900*sy), sx/2, sy/2, tocolor(255, 255, 255, alpha_selection["forest"]), scale, slender_font, "left", "top", false, false, true) dxDrawText("INDUSTRY", sx/2-(270/1600*sx), sy/2-(5/900*sy), sx/2, sy/2, tocolor(255, 255, 255, alpha_selection["forest"]), scale, slender_font, "left", "top", false, false, true) dxDrawText("FOREST", sx/2-(270/1600*sx), sy/2-(-115/900*sy), sx/2, sy/2, tocolor(255, 255, 255, alpha_selection["forest"]), scale, slender_font, "left", "top", false, false, true) end end
-
Make sure that the error is about your resource. If not, then do not care about it. If it's about your resource, then make sure that "your xml" is called meta.xml and not Meta.xml or meta.xml.txt On windows 7, the extensions aren't shown by default in the explorer. A screenshot of what's is in your resource (not the code) would let us verify that last point (on the screenshot, be sure we can see the "Type" column ). Regards, Citizen
-
where do i do this? don't i just make a new lua and do this? It's easier to edit the source code of the zombie mod and use set/getElementDimension functions to make the zombies visible in a specific dimension, only targeting players that are in the same dimension. The zombies sounds have to be played only for the players that are in the same dimension too etc.