-
Posts
7,337 -
Joined
-
Days Won
11
Everything posted by TAPL
-
(p) is parameter playerSource: The player who triggered the command. https://wiki.multitheftauto.com/wiki/AddCommandHandler
-
function setElementSpeed(element, unit, speed) -- only work if element is moving! if (unit == nil) then unit = 0 end if (speed == nil) then speed = 0 end speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) if (acSpeed~=false) then -- if true - element is valid, no need to check again local diff = speed/acSpeed local x,y,z = getElementVelocity(element) setElementVelocity(element,x*diff,y*diff,z*diff) return true end return false end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end function turn(thePlayer) local vehicle = getPedOccupiedVehicle(thePlayer) if (not vehicle) then return end local rX, rY, rZ = getVehicleRotation(vehicle) local Speeds = getElementSpeed(vehicle, "mph") setElementRotation(vehicle, rX, rY, rZ + 180) local Boost = 0.001 setTimer(setElementSpeed,50,1,vehicle,1,-Speeds+Boost) outputChatBox("#00FF00You turned your vehicle with #FF0000" .. tostring(Speeds) .. " mph", thePlayer) end function bindTheKey(p) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(p)),aclGetGroup("Admin")) then for index, player in pairs(getElementsByType("player")) do bindKey(player, "lctrl", "down", turn) outputChatBox("#00FF00You can press #0000FF'left ctrl' #00FF00in vehicle to turn for 180 degrees!", player, 255, 255, 255, true) end end end addCommandHandler("turningON",bindTheKey) function unBindTheKey(p) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(p)),aclGetGroup("Admin")) then for index, player in pairs(getElementsByType("player")) do unbindKey(player, "lctrl", "down", turn) outputChatBox("#FF0000Turning disabled!", player, 255, 255, 255, true) end end end addCommandHandler("turningOFF",unBindTheKey)
-
This is server side of the script (rules_s): function acceptRules(button,state) if button == "left" and state == "up" then guiSetVisible(rulesWindow, false) showCursor(false,false) outputChatBox("You successfully accept our rules, enjoy playing.") if rulesWarningTimer then killTimer(rulesWarningTimer) rulesWarningTimer = nil end end end function inactivePlayer(status) if status == 1 then outputChatBox("Please accept our rules or you will be kicked.") rulesWarningTimer = setTimer(inactivePlayer,30000,1,2) elseif status == 2 then outputChatBox("Second Warning: Please accept our rules you will be kicked.") rulesWarningTimer = setTimer(inactivePlayer,30000,1,3) elseif status == 3 then outputChatBox("Last Warning: Please accept our rules you will be kicked.") rulesWarningTimer = setTimer(inactivePlayer,30000,1,3) elseif status == 4 then triggerServerEvent("clientKickInactivePlayer",getLocalPlayer()) end end addEvent("clientKickInactivePlayer",true) addEventHandler("clientKickInactivePlayer",root,kickInactivePlayer) Thank you for your help. is this server side? triggerServerEvent is this server side? getLocalPlayer() is this server side? guiSetVisible(rulesWindow, false)
-
also this https://community.multitheftauto.com/index.php?p= ... ts&id=1139
-
function [color=#FF0000]win[/color](ammo, killer, weapon, bodypart) addEventHandler( "onPlayerWasted", getRootElement(), [color=#FF0000]Win[/color])
-
what i post do that
-
function excelToDriver (target) if (target) and getElementType(target) == "vehicle" and getPedWeapon(localPlayer) == 23 and getControlState("aim_weapon") then speedx, speedy, speedz = getElementVelocity(target) actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) kmh = actualspeed * 180 outputChatBox("* Prędkość namierzonego pojazdu wynosi: "..math.floor(tonumber(kmh)).. " KM/h.",255,255,255,true) end end addEventHandler("onClientPlayerTarget",localPlayer,excelToDriver)
-
-- From Useful Functions ! function setElementSpeed(element, unit, speed) -- only work if element is moving! if (unit == nil) then unit = 0 end if (speed == nil) then speed = 0 end speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) if (acSpeed~=false) then -- if true - element is valid, no need to check again local diff = speed/acSpeed local x,y,z = getElementVelocity(element) setElementVelocity(element,x*diff,y*diff,z*diff) return true end return false end ----- function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end ------ function turn(thePlayer) local vehicle = getPedOccupiedVehicle(thePlayer) if (not vehicle) then return end local rX, rY, rZ = getVehicleRotation(vehicle) local Speeds = getElementSpeed(vehicle, "mph") setElementRotation(vehicle, rX, rY, rZ + 180) local Boost = 0 -- You Can set this to 0 if You Dont Need it ! setTimer(setElementSpeed,50,1,vehicle,1,-Speeds+Boost) -- i used timer to set the car speed after rotation 1 outputChatBox("You turned your vehicle with " .. tostring(Speeds) .. " mph", thePlayer) end function bindTheKey() for index, player in pairs(getElementsByType("player")) do bindKey(player, "lctrl", "down", turn) outputChatBox("#00FF00You can now press #0000FF'left ctrl' #00FF00in vehicle to turn for 180 degrees!", player, 255, 255, 255, true) end end addEventHandler("onResourceStart", resourceRoot, bindTheKey) addEventHandler("onPlayerJoin", root, function() bindKey(source, "lctrl", "down", turn) end)
-
wtf? addEventHandler("onPlayerWasted", resourceRoot, deanimated)
-
function clear(player) if hasObjectPermissionTo(player, "function.setPlayerMuted", false) then for i=1,30 do outputChatBox(" ") end outputChatBox("* #ff0000INFO:#ffff00ADMIN #00ff00"..getPlayerName(player).." #ffff00CLEARED THE CHAT",root,255,12,15, true) else outputChatBox ("You are Not Admin", player, 193, 13, 13) end end addCommandHandler("cc", clear)
-
what? edit the script as you need we're not in your head to know what you want
-
Client Side local Protect = false function OnSpawn() Protect = true setTimer(function() Protect = false triggerServerEvent("ShowMsg",localPlayer) end, 5000, 1) end addEventHandler("onClientPlayerSpawn",localPlayer,OnSpawn) function ProtectDamage() if (Protect) then cancelEvent() end end addEventHandler ("onClientPlayerDamage",localPlayer,ProtectDamage) Server Side function msg() outputChatBox(getPlayerName(source).." is No Not Protected!",root,255,255,0,true) end addEvent("ShowMsg",true) addEventHandler ("ShowMsg",root,msg)
-
what do you mean 'Spawn Protect' ?
-
No. https://wiki.multitheftauto.com/wiki/SetClipboard This function sets the players clipboard text (what appears when you paste with CTRL + V) Note that there is no getClipBoard function for safety reasons.
-
local gui = {} gui["menuRoleplayType"] = guiCreateComboBox(160, 185, 111, 180,"", false, gui["_root"]) gui["btnAccept"] = guiCreateButton(90, 500, 101, 41, "Accept", false, gui["_root"]) addEventHandler("onClientGUIChanged", gui.menuRoleplayType, function(element) outputDebugString("Menu Char Skin has been changed and it's value is " .. guiGetText(element)) end) addEventHandler("onClientGUIClick", gui.btnAccept, function(button, state) if button == "left" and state == "up" then outputDebugString("Accept button has been clicked by client") end end)
-
addEventHandler("onClientGUIChanged", menuCharSkin,function(element) outputDebugString("Menu Char Skin has been changed and it's value is " .. guiGetText(element)) end) addEventHandler("onClientGUIClick", btnAccept, function(button, state) if button == "left" and state == "up" then outputDebugString("Accept button has been clicked by client") end end)
-
The first code works Thanks for help
-
hello does any one know how to make an function that check if the string is ASCII characters or none ASCII characters? !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ if is ASCII characters then it will returned true else false.. function xxx(player,cmd,text) if isASCII(text) then outputChatBox("it's ASCII characters!",root) else outputChatBox("it's not ASCII characters!",root) end end addCommandHandler("check",xxx) function isASCII(text) ????? return true end
-
viewtopic.php?f=91&t=37249
-
function getPlayerFromPartOfName(playerPart) local pl = getPlayerFromName(playerPart) if isElement(pl) then return pl else for i,v in ipairs (getElementsByType ("player")) do if (string.find(getPlayerName(v),playerPart)) then return v end end end end addEvent("jail",true) addEventHandler("jail",root, function(IM,HIM) if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(IM)), aclGetGroup ( "Admin" ) ) then local thePlayer = getPlayerFromPartOfName(HIM) local theVehicle = getPedOccupiedVehicle(thePlayer) if not thePlayer then return end if theVehicle then removePedFromVehicle(thePlayer) end if getElementData( thePlayer, "isJailed") then outputChatBox("This player is already in jail.",IM,255,0,0) return end setElementInterior ( thePlayer, 0 ) setElementPosition (thePlayer, -2354.158203125, 1922.5645751953, 693.34704589844) setElementData ( thePlayer, "isJailed", true ) outputChatBox (name.." you are in jail now", getRootElement(), 255, 0, 0, true ) showPlayerHudComponent (thePlayer, "weapon", false) else outputChatBox ("Access denied", thePlayer, 193, 13, 13) end end) addEvent("unjail",true) addEventHandler("unjail",root, function(IM,HIM) if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(IM)), aclGetGroup ( "Admin" ) ) then local thePlayer = getPlayerFromPartOfName(HIM) if thePlayer then if not getElementData( thePlayer, "isJailed") then outputChatBox("This player is not in jail.",IM,255,0,0) return end setElementInterior ( thePlayer, 0) setElementPosition ( thePlayer, -2313.3076171875, 1902.7426757813, 9.9688625335693) setElementData ( thePlayer, "isJailed", false ) outputChatBox (name.."yor are out the jail now"..name, getRootElement(), 0, 255, 0, true ) else outputChatBox ("Access denied", thePlayer, 193, 13, 13) end end end)
-
the server side look like not your who make.
-
this just will making an stupid thing