-
Posts
6,097 -
Joined
-
Last visited
-
Days Won
218
Everything posted by IIYAMA
-
@Dzsozi Did you know that with your code every player has to be in a vehicle to hear a sound? and if they are not they get 3 warnings at clientside? Because you don't check if the vehicle does exist. try: -- server triggerClientEvent ("onMotorSerult",veh) -- client addEvent ("onMotorSerult",true) addEventHandler ("onMotorSerult",root, function () if isElement(source) then local x, y, z = getElementPosition(source) local motor = playSound3D("startup.mp3", x, y, z, false) setSoundMaxDistance(motor, 30) end end )
-
By using the second example + cancelEvent() of my previous post. addEventHandler("onClientPlayerChoke", root, function (weapon,attacker) if weapon == 41 then outputChatBox("hit with spraycan > onClientPlayerChoke ") cancelEvent() end end) You have to read the information better from the event's. Only events that have information about cancelling events can do that, others cannot.
-
addEventHandler("onClientPlayerWeaponFire", root, function (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement, startX, startY, startZ) local attacker = source if weapon == 41 then if getDistanceBetweenPoints3D (hitX, hitY, hitZ,startX, startY, startZ) < 3 then -- anti bug outputChatBox('spraycan hit') end else outputChatBox('1') end end) Or you can use:(this event can cancel the damage/animation) addEventHandler("onClientPlayerChoke", root, function (weapon,attacker) if weapon == 41 then outputChatBox("hit with spraycan > onClientPlayerChoke ") end end)
-
-- Server: -- create your colshape function onColEvent( p ) if ( getElementType ( p ) == "vehicle" ) then p = getVehicleOccupant ( p ) end if ( not isElement ( p ) ) then return end if ( eventName == "onColShapeHit" ) then setElementData ( p, "isClientInProtectedArea", true ) else setElementData ( p, "isClientInProtectedArea", false ) end triggerClientEvent ( p, "onClientProtectedAreaEventChange", p, eventName ) end addEventHandler ( "onColShapeHit", CSSZ1, onColEvent ) addEventHandler ( "onColShapeLeave", CSSZ1, onColEvent ) -- client addEventHandler ( "onClientPlayerDamage", root, function ( ) if ( getElementData ( source, "isClientInProtectedArea" ) ) then cancelEvent ( ) end end ) addEvent ( "onClientProtectedAreaEventChange", true ) addEventHandler ( "onClientProtectedAreaEventChange", root, function ( e ) if ( e == "onColShapeHit" and not isRender ) then [color=#FF0000] render = true[/color] addEventHandler ( "onClientRender", root, onClientRender ) elseif ( e == "onColShapeLeave" ) then [color=#FF0000] render = false[/color] end end ) [color=#FF8000]local[/color] [color=#FF0000]isRender = false[/color] local sWidth,sHeight = guiGetScreenSize() function onClientRender ( ) if ( not [color=#FF0000]isRender[/color] ) then removeEventHandler ( "onClientRender", root, onClientRender ) end dxDrawText("Protected Area Comp",sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,0,255),1.0,"pricedown","left","bottom",false,false,false) end It is obviously. The names don't match and the variable should be on top of the code (local variables).
-
ok very strange. You can report the bug if you want. https://bugs.multitheftauto.com/my_view_page.php But to solve your problem, you can use "onClientPlayerWeaponFire" + getDistanceBetweenPoints3D(because of the strange weapon range)
-
Line: 15 givePlayerMoney(killer,getPlayerMoney(killer) 0) I am not sure what you wanted to do. givePlayerMoney(killer,tonumber(getPlayerMoney(killer) .. 0)) -- or givePlayerMoney(killer,getPlayerMoney(killer)) -- or givePlayerMoney(killer,1000)
-
You sure there are no events get cancelled? (in another script)
-
Not really since that only get triggered when a player change from target and not when he starts aiming. The best result would be using bindkey, but will require more bandwidth.
-
I am not going to make it exact as you want, it is your code. Use: https://wiki.multitheftauto.com/wiki/GetControlState To check if somebody is aiming.
-
of course it isn't working. The variable player is nil is nothing and useless, when you don't define it. setTimer (function () local players = getElementsByType("player") for i=1,#players do local player = players[i] local target = getPedTarget (player) if target and getElementType (target) == "vehicle" then destroyElement (target) end end end, 500,0)
-
https://forum.multitheftauto.com/viewtopic.php?f=91&t=73326
-
If you bought it then you should go back to them. We don't give support to leaked scripts.
-
The code shows your mistake directly. You were not wondering why most of it was red? exports [ "TopBarChat" ] : sendClientMessage ( [color=#FF0000][b] "[/b][/color]the mission Coming Soon", player, 255, 0, 0, true )
-
Use more locals at the right places or people can get problems. Especially when you use the variable (which is used often) as a global. Also: for i,v in ipairs(PTable) do for k,s in pairs(PTableValues) do if v == s then TableReturn[k] = i break end end end Why do you do this? What is the use of it, when the tables contain the same information but at a differed array location?
-
Try: function createVIPTeam () vipTeam = createTeam ( "VIP", 255, 0, 0 ) end addEventHandler("onResourceStart", resourceRoot, createVIPTeam) too: --[[function createVIPTeam ()]] vipTeam = createTeam ( "VIP", 255, 0, 0 ) --[[end addEventHandler("onResourceStart", resourceRoot, createVIPTeam)]] onResourceStart has a delay till all code has been loaded. I am not sure if that is the problem, but it is possible when players login automatic.
-
ok, local env = {} setfenv(user_script, env) pcall(user_script) Using setfenv I can prevent this? But after I set this environment. Will the code inside the environment able to access global variables (read or/and write)? Or just calling other functions disabled? Note: All the code that I am going to load is written by myself and doesn't come from the maps but from the gamemode. The gamemode sends the code which fits with the map.
-
aha, Well I am not going to save the scripts I load via loadstring on the players their harddrive. More like loading modus per map, which is send from the server. But if I do save them, how can a sandbox prevent this?
-
I have never worked with Environments. I found this: http://lua-users.org/wiki/SandBoxes As far as I understand it is a kind of security for the code. What can happen if I don't use a sandbox?
-
@WhoAmI No, it doesn't work since you skipped they key arguments of the bindKey at the function payTheTicket. I you don't know what I mean, click on the link to his other topic about the same script. @#Twerky Would you pls not post everything double? You won't get better results, but mad moderators if that is what you want... https://forum.multitheftauto.com/viewtopic.php?f=91&t=73202
-
bindKey ( source, "H", "down", payTheTicket, source) function payTheTicket (theCop,key,keyState,source) https://wiki.multitheftauto.com/wiki/BindKey Server bindKey ( player thePlayer, string key, string keyState, function handlerFunction, [ var arguments, ... ] ) function functionName ( player keyPresser, string key, string keyState, [ var arguments, ... ] )
-
It must be, element data doesn't change automatic. Unless the teamscore get set at clientside with synchronisation to false, which would be a very strange habit.
-
So I must use it like this? dataForTheFunctionInside = {"my name is IIYAMA","apple","what ever"}-- must be global local callThisFunction = "function myFunction(data) outputChatBox(next(data)) end myFunction(dataForTheFunctionInside)" local callLoadString = function () local loaded = loadstring(callThisFunction) local ex = pcall(loaded) if ex then outputChatBox("loaded the code") end end addCommandHandler("loadstring",callLoadString) (no tested)
-
Where do you see Samer? O_o Root is more efficient, since it only can be send to players. A loop will call the outputChatBox function over and over, which uses much more memory. You can test that with getTickCount(), if you don't believe me.
-
np. oh My bad, it was onClientPlayerChoke. I was confused because some ped functions are also for players. addEventHandler("onClientPlayerChoke",localPlayer, function (weapon) if weapon == 41 then cancelEvent( ); end end ) But I don't think you need it since you already use onClientPlayerDamage.
