-
Posts
297 -
Joined
-
Last visited
Everything posted by Bonus
-
Sry, but I'm absolutely sure that's not the case. The garbage collector in Lua isn't that stupid. Also a local table would get erased, too, because it get's passed by reference like a function. But we can use tables to pass optional parameters in dbQuery, that's why your idea is impossible.
-
Hey, I always wondered why there is this information: "The function is called with the query handle as the first argument. (Notice: Do not use a function with a local prefix)" Here: https://wiki.multitheftauto.com/wiki/DbQuery I've never had any problems with local functions in dbQuery. Is the notice old or is there something I don't know?
-
You could do it with onVehicleEnter, bindKey etc.
-
Go in the language folder and change it in the language file.
-
Oh sry, didn't read the /vi function well The shared function got some problems. Try this: addCommandHandler ( "share", function ( player, _, targetname ) -- the parameter-name should describe what the parameter is! if targetname then -- did the player even use a name? local target = getPlayerFromName ( targetname ) if target then -- is the target online? does he even exist? local vehicle = getPedOccupiedVehicle ( player ) if vehicle then -- does the player sit in a vehicle? if getPedOccupiedVehicleSeat ( player ) == 0 then -- is the player the driver -- optional -- if not players[vehicle] then players[vehicle] = {} end --------------- local targetserial = getPlayerSerial ( target ) if players[vehicle][1] then -- the table name is really bad for i=1, #players[vehicle] do -- fastest loop if players[vehicle][i] == targetserial then -- if the targetserial is already in table.remove ( players[vehicle], i ) outputChatBox ( "Vehicle unshared with "..targetname.."!", player, 0, 255, 255 ) outputChatBox ( getPlayerName ( player ).." has denied you access to their vehicle!", 0, 255, 255 ) return -- stop the function HERE end end end -- if the vehicle wasn't shared with target -- players[vehicle][#players[vehicle]+1] = targetserial outputChatBox ( "Vehicle shared with "..targetname.."!", 0, 255, 255 ) outputChatBox ( getPlayerName ( player ).." has granted you access to their vehicle!", 0, 255, 255 ) else outputChatBox ( "You are not the driver of that vehicle", player, 255, 0, 0 ) end else outputChatBox ( "You are not sitting in a vehicle", player, 255, 0, 0 ) end else outputChatBox ( "The target doesn't exist or is offline", player, 255, 0, 0 ) end else outputChatBox ( "Usage: /share [target]", player, 255, 0, 0 ) end end ) Your code was a bit weird. You looped through the table without stopping. In the loop you put the serial in the table, if the serial is already in And removed the serial when it wasn't even in.
-
And WHAT doesn't work? /vi can't work, cause the parameter vehicle and value1 are strings. vehicle isn't a vehicle, it's only a string. /vi Hello my -> vehicle = "Hello", value1 = "my"
-
1. Use the code function 2. The name of the function is totally irritating. 3. Can't you just use it clientsided? 4. Else you have to use triggerClientEvent. 5. You only use addEvent when you create a new custom event. onColShapeHit isn't a custom event. 6. You cant use the Event onClientRender serversided. 7. dxDraw is a clientsided function here, so you can't use it serversided. 8. You should use onColShapeLeave too
-
It's the local chat ... Loops through every player and outputs the chat to him, if he is max. 50 away
-
Where do you get valor?
-
Have to admit, Bonsai was right. It's faster to use getElementsByType and getDistanceBetweenPoints3D instead of using a colshape. Tested it on my server, the getDistanceBetweenPoints3D way was like 3-4x faster, needed 1ms to use it on 500 peds. But in my eyes it's still much better than to trigger it to every player. So you should better use getElementsByType and getDistanceBetweenPoints3D. local text = "Hi" local x, y, z = getElementPosition ( player ) local players = getElementsByType ( "player" ) for i=1, #players do -- fastest loop local xp, yp, zp = getElementPosition ( players[i] ) if getDistanceBetweenPoints3D ( x, y, z, xp, yp, zp ) <= 50 then outputChatBox ( players[i], text, 200, 200, 200 ) end end
-
Don't worry, it's working good. Your way would use bandwith and the client CPU. That's not better, that's worse. 50 players on a spot? Means 50 triggerClientEvent at 1 chat.
-
xyz solution will work good, if you use it for a low amount of player. If the amount is high the script can lag your server. A safer solution is a colshape. Create a colshape with radius 50, get all players in it with a colshape and getElementsWithinColshape and loop through them without asking the position.
-
The unpack version is slower than the first solution. So better use the first solution, not the one with unpack. Don't forget to use fadeCamera and setCameraTarget.
-
What are you trying to do? If you create a pickup clientsided the other players won't see it. So you don't need to trigger the pickup or the alpha, cause only the creator-client will see it. But if you want to create a pickup for all clients and then want to change the alpha at all clients you have to trigger the alpha from the server to all clients. Don't know why you guys trying to trigger the clientsided pickup. Why should player y know about the pickup created by player x clientsided. Player y will never see that pickup. -- server -- addCommandHandler ( "changepickupalpha", function ( player, _, alpha ) triggerClientEvent ( "changePickupAlpha", player, tonumber ( alpha ) or 255 ) end ) -- client -- local pickup = createPickup ( ... ) addEvent ( "changePickupAlpha", true ) addEventHandler ( "changePickupAlpha", root, function ( alpha ) setElementAlpha ( pickup, alpha ) end )
-
Use getAccount ( "WalkinG" ) to get the account. First argument in getAccountData and setAccountData has to be an account, so you can't just use a string and expect it to work.
-
Then trigger (from server to client) the alpha and change the alpha of the pickup to this triggered alpha. You can't trigger directly from client to client.
-
Hey, I bet most of you know this bug: You run into the opponent, which is boxing with his hand into nothing. But the player is normally shooting with his weapon, but it's not synced well. So you can't see his weapon even if he got one and is shooting at you. Does someone know a solution for this problem?
-
pairs goes through a table without sorting, so you can use it with every table/index. ipairs first sorts the table by index (only integer), then goes through. pairs is more safe and fast, you can go through every table with that ipairs only goes from 1 to the highest index before a index with nil value. ipairs is something like this: local table = { ... } local i =1 while table[i] do --- i = i + 1 end Index NOT integer(number) -> pairs Index integer, but dont want to sort it -> pairs Index integer, but with nil values between other values -> pairs Index integer and you want to sort it -> for i=1, #table do To be honest: I don't really know why so many guys still use ipairs. for i=1, #table do is much faster, you just have to check before using if the "table" is really a table and if the table got atleast one value: local thetable = {} if thetable and thetable[1] then for i=1, #thetable do end end I only know 1 only usage for ipairs: When you want to go through the table from 1 to n and want to remove from the table. You could still remove from the table, but only when you go through the table from n to 1. return stops a function and returns something. Example: function getPlayerRotation ( player ) local _, _, zr = getElementRotation ( player ) if zr then return zr end return false -- return false if zr wasn't already returned outputChatBox ( "This outputChatBox will never get executed" ) end local rot = getPlayerRotation ( player ) But break just stops a loop (while, for, repeat) local name = "Bonus" local players = getElementsByType ( "player" ) for i=1, #players do -- the loop if getPlayerName ( players ) == name then outputChatBox ( "Player-Name was found" ) break -- stops the loop end end
-
Google told me: "If you get 1.#IND or nan, look for illegal operations." Seems like 1.#IND and 1.#QNAN are similar. You can test with debugscript every variable. So you could see which of these variables cause the problem.
-
"Put this code before the lines which let you get the warnings:" BEFORE, not after ...
-
I think it's because you activate "action" somewhere again. Cause if you deactivate "action" the player can't shoot. Maybe try this: -- client -- local _toggleAllControls = toggleAllControls function toggleAllControls ( ... ) local result = _toggleAllControls (... ) toggleControl ( "action", false ) return result end -- server -- local _toggleAllControls = toggleAllControls function toggleAllControls ( ... ) local result = _toggleAllControls (... ) local data = { ... } local player = data[1] if isElement ( player ) then toggleControl ( player, "action", false ) end return result end That way "action" can't get activated again by toggleAllControls.
-
Can you please show me where you put the line?
-
... Again: Put this code before the lines which let you get the warnings: outputDebugString ( tostring (objx).."-"..tostring(objy).."-"..tostring(objz).." | "..tostring(offrx).."-"..tostring(offry).."-"..tostring(offrz) ) Then try to get the warning again. If you get the warning look at the output 1 line BEFORE the warning. What is written there?
-
When you get the warning, what is the output before the two warnings?
-
You said you got warnings ... now you don't get warnings?
