MrSecreto07 Posted May 13, 2017 Share Posted May 13, 2017 hi community! I would like to know if anyone can help me, I want this glue script to work only for members of a team. I have tried everything and I can not do it, if you help me I would appreciate it. Client: function glue() local player = getLocalPlayer() if not getPlayerOccupiedVehicle(player) then local vehicle = getPlayerContactElement(player) if getElementType(vehicle) == "vehicle" then local px, py, pz = getElementPosition(player) local vx, vy, vz = getElementPosition(vehicle) local sx = px - vx local sy = py - vy local sz = pz - vz local rotpX = 0 local rotpY = 0 local rotpZ = getPlayerRotation(player) local rotvX,rotvY,rotvZ = getVehicleRotation(vehicle) local t = math.rad(rotvX) local p = math.rad(rotvY) local f = math.rad(rotvZ) local ct = math.cos(t) local st = math.sin(t) local cp = math.cos(p) local sp = math.sin(p) local cf = math.cos(f) local sf = math.sin(f) local z = ct*cp*sz + (sf*st*cp + cf*sp)*sx + (-cf*st*cp + sf*sp)*sy local x = -ct*sp*sz + (-sf*st*sp + cf*cp)*sx + (cf*st*sp + sf*cp)*sy local y = st*sz - sf*ct*sx + cf*ct*sy local rotX = rotpX - rotvX local rotY = rotpY - rotvY local rotZ = rotpZ - rotvZ local slot = getPlayerWeaponSlot(player) --outputDebugString("gluing ".. getPlayerName(player) .." to " .. getVehicleName(vehicle) .. "(offset: "..tostring(x)..","..tostring(y)..","..tostring(z).."; rotation:"..tostring(rotX)..","..tostring(rotY)..","..tostring(rotZ)..")") triggerServerEvent("gluePlayer", player, slot, vehicle, x, y, z, rotX, rotY, rotZ) unbindKey("x","down",glue) bindKey("x","down",unglue) bindKey("jump","down",unglue) end end end addCommandHandler("glue",glue) function unglue () local player = getLocalPlayer() triggerServerEvent("ungluePlayer", player) unbindKey("jump","down",unglue) unbindKey("x","down",unglue) bindKey("x","down",glue) end addCommandHandler("unglue",unglue) bindKey("x","down",glue) Server: function gluePlayer(slot, vehicle, x, y, z, rotX, rotY, rotZ) attachElementToElement(source, vehicle, x, y, z, rotX, rotY, rotZ) setPlayerWeaponSlot(source, slot) end addEvent("gluePlayer",true) addEventHandler("gluePlayer",getRootElement(),gluePlayer) function ungluePlayer() detachElementFromElement(source) end addEvent("ungluePlayer",true) addEventHandler("ungluePlayer",getRootElement(),ungluePlayer) Link to comment
#BrosS Posted May 13, 2017 Share Posted May 13, 2017 use getPlayerTeam and getTeamName as a condition so the event won't apply if the player is not in the team Link to comment
Function Posted May 14, 2017 Share Posted May 14, 2017 (edited) if not getPlayerTeam(player) then outputChatBox("You must be in a team to glue on a vehicle.",player,255,0,0) return end Edited May 14, 2017 by Function Link to comment
#BrosS Posted May 14, 2017 Share Posted May 14, 2017 (edited) 5 hours ago, Function said: if not getPlayerTeam(player) then outputChatBox("You must be in a team to glue on a vehicle.",player,255,0,0) return end he said a member of a team not in a team Edited May 14, 2017 by #BrosS Link to comment
Function Posted May 14, 2017 Share Posted May 14, 2017 2 hours ago, #BrosS said: he said a member of a team not in a team Thats the same. Link to comment
Captain Cody Posted May 14, 2017 Share Posted May 14, 2017 AllowedTeams = {} AllowedTeams["TeamName"] = true function gluePlayer(slot, vehicle, x, y, z, rotX, rotY, rotZ) if getPlayerTeam(source) then if AllowedTeams[getTeamName(getPlayerTeam(source))] then attachElementToElement(source, vehicle, x, y, z, rotX, rotY, rotZ) setPlayerWeaponSlot(source, slot) end end end addEvent("gluePlayer",true) addEventHandler("gluePlayer",getRootElement(),gluePlayer) function ungluePlayer() detachElementFromElement(source) end addEvent("ungluePlayer",true) addEventHandler("ungluePlayer",getRootElement(),ungluePlayer) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now