Jump to content

[HELP] Glueing system.


DonOmar

Recommended Posts

Well if you could be more clear about what you are asking maybe just maybe I could actually help. I'm tired of all these people in the English scripting section that don't speak a word of proper English asking for scripting help.

And if you want to question my scripting abilities, please go ahead and take a look at the first link in my signature.

Link to comment

ok look at this i made the glue system in server side but when a player is trying to glue on my car he can't . just me can glue on my car. here is the code

function gluePlayer(player, slot, vehicle, x, y, z, rotX, rotY, rotZ) 
    attachElements(player, vehicle, x, y, z + 0.16, rotX, rotY, rotZ) 
    setPedWeaponSlot(player, slot) 
    setElementData(player, "gluedYe", true) 
end 
  
  
function unglue(source, key, state) 
    detachElements(source) 
    setElementData(source, "gluedYe", false) 
end 
  
  
function glue(_, element) 
    if not getPedOccupiedVehicle(source) then  
       local owner = getElementData(element, "Owner") 
       local gmate = getElementData(source, "g") 
       local gmate2 = getElementData(owner, "g") 
       local smate = getElementData(source, "s") 
       local smate2 = getElementData(owner, "s") 
       if (getElementData(vehicle, "locked") == true) and not (owner == source) or not (gmate == gmate2) or not (smate == smate2)  then 
            exports.CIThelp:displayAttachedHelp(0, 0, 1, vehicle, "Vehicle is locked by the owner only group/squad members can glue to it", 1, 255, 0, 0, 180, 5000)  
            return  
        elseif getElementType(element) == "vehicle" then --and getElementData(source, "CIFvip") == true or (getTeamName(getPlayerTeam(source)) == "Staff") then 
            local px, py, pz = getElementPosition(source) 
            local vx, vy, vz = getElementPosition(element) 
            local sx = px - vx 
            local sy = py - vy 
            local sz = pz - vz 
            local rotpX = 0 
            local rotpY = 0 
            local rotpZ = getPedRotation(source) 
            local rotvX,rotvY,rotvZ = getElementRotation(element) 
            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 = getPedWeaponSlot(source) 
            gluePlayer(source, slot, element, x, y, z, rotX, rotY, rotZ) 
            bindKey(source,"jump","down",unglue) 
            bindKey(source,"w","down",unglue) 
            bindKey(source,"a","down",unglue) 
            bindKey(source,"s","down",unglue) 
            bindKey(source,"d","down",unglue) 
        end 
    end 
end 
addEventHandler("onPlayerContact", root, glue) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...