Jump to content

[Help]-Fix-Script


SoMoRay

Recommended Posts

hi guys I do spawn

but there proplem

see the picture

2JRiX.png

I can't change team with I

click in arrow right

and arrow left

this is

Client

GUIEditor = { 
    button = {}, 
} 
spawn = guiCreateButton(583, 690, 191, 58, "Spawn", false) 
guiSetFont(GUIEditor.button[1], "clear-normal") 
  
addEventHandler("onClientGUIClick",spawn,  
  
function () 
  
triggerServerEvent("setTeam",localPlayer) 
  
end) 
  
  
  
  
addEventHandler("onClientGUIClick",spawn,  
  
function () 
  
triggerServerEvent("setTeam2",localPlayer) 
  
end) 
  

Server

Team = createTeam ("Rebel",255,0,0) 
  
  
addEvent("setTeam",true) 
  
  
  
addEventHandler("setTeam",root, 
  
  
  
function (theplayer1) 
    bindKey("arrow_r", "down",theplayer1)  
     
 setCameraMatrix( theplayer, 1568.5963134766, -1691.4530029297, 5.890625) 
  
  
  
 setPlayerTeam(source,Team) 
  
 spawnPlayer (source, 1568.5963134766, -1691.4530029297, 5.890625,0,1,0,1,Team) 
  
  Anims = {"dnce_M_b","DAN_Left_A","DAN_Down_A","DAN_Loop_A"}  
  
 setPedAnimation( ped, "DANCING", Anims[math.random(1,4)])  
  
 ped = createPed (1,1568.5963134766,-1691.4530029297,5.890625) 
  
  pedSkin = getElementModel(ped) 
  
  setElementModel(ped,id) 
  
  giveWeapon ( source, 30, 9999,true ) 
  
  giveWeapon ( source, 31, 9999,true ) 
  
     setTeamFriendlyFire ( getTeamFromName("Rebel"),false)  
  
    outputChatBox ( "#FF0000 You Take Rebel Team !", 255, 255, 255, true ) 
     
  
end 
) 
  
  
  
Team2 = createTeam ("Police",255,0,0) 
  
  
addEvent("setTeam2",true) 
  
  
  
addEventHandler("setTeam2",root, 
  
  
  
function (theplayer2) 
     
    bindKey("arrow_l", "down",theplayer2)  
     
    setCameraMatrix( theplayer, 1485.0311279297, -2234.9086914063, 13.546875) 
  
   
 Anims = {"dnce_M_b","DAN_Left_A","DAN_Down_A","DAN_Loop_A"}  
   
 setPedAnimation( ped, "DANCING", Anims[math.random(1,4)])  
  
 ped = createPed (280, 1485.0311279297, -2234.9086914063, 13.546875) 
  
 pedSkin = getElementModel(ped) 
  
  setElementModel(ped,id) 
     
  spawnPlayer (source, 1485.0311279297, -2234.9086914063, 13.546875,0,280,0,0,Team2) 
  
    giveWeapon ( source, 30, 9999,true ) 
  
    giveWeapon ( source, 31, 9999,true ) 
     
    setTeamFriendlyFire ( getTeamFromName("Police"),false) 
  
  outputChatBox ( "#FF0000 You Take Police Team !", 255, 255, 255, true ) 
  
end 
) 
  
Link to comment

playSound 
"onClientResourceStart" 
stopSound 
"onClientGUIClick" 
  

For Example :

addEventHandler("onClientResourceStart",resourceRoot, function ()  
sound = playSound("File.mp3",true) end) 
  

addEventHandler("onClientGUIClick",button, function () 
stopSound(sound) sound = nil end) 

:)

Link to comment
playSound 
"onClientResourceStart" 
stopSound 
"onClientGUIClick" 
  

For Example :

addEventHandler("onClientResourceStart",resourceRoot, function ()  
sound = playSound("File.mp3",true) end) 
  

addEventHandler("onClientGUIClick",button, function () 
stopSound(sound) sound = nil end) 

Bz6ym.png

what proplem I put ur code

for play sound

he kick me from server

and said wrong code

Download error: Error downloading requested files. HTTP response code said error. [The requested URL returned error: 404] [spawn@00/Client.lua] 
  

Client Side !

  
x, y = guiGetScreenSize ( ) 
function centerWindow ( center_window, k, v ) 
  
    local screenW, screenH = guiGetScreenSize ( ) 
  
    local windowW, windowH = guiGetSize ( center_window, false ) 
  
    local x, y = ( screenW - windowW ) / v, ( screenH - windowH )/k 
  
    guiSetPosition ( center_window, x, y, false ) 
  
end 
  
addEventHandler("onClientResourceStart",resourceRoot, function ()  
  
sound = playSound("Alhajarii.mp3",true) 
end) 
  
thePed = createPed ( 1, 0, 0, 500, 90 ) 
  
setElementFrozen ( thePed, true ) 
  
setCameraMatrix ( -3.6658203125, 0, 500.48254455566, 2906.9938964844, 0, 201.84664916992 ) 
  
Animations = { "dnce_M_b"} 
  
setPedAnimation( thePed, "DANCING", Animations [ math.random ( #Animations ) ] ) 
  
theObject = createObject ( 1337, 0, 0, 499, 60 ) 
  
setElementAlpha ( theObject, 0 ) 
  
SpawnBtn = guiCreateButton( 0, 0, 125, 62.5, "Spawn", false ) 
  
centerWindow ( SpawnBtn, 1.2, 1.96 ) 
  
RightBtn = guiCreateButton( 0, 0, 70, 35, ">", false ) 
  
centerWindow ( RightBtn, 2, 1.4 ) 
  
LeftBtn = guiCreateButton( 0, 0, 70, 35, "<", false ) 
  
centerWindow ( LeftBtn, 2, 3.3 ) 
  
showCursor ( true ) 
  
  
  
function Right ( ) 
  
    if ( isElement ( thePed ) ) then 
  
        if ( getElementModel ( thePed ) ~= 280 ) then 
  
            setElementModel ( thePed, 280 ) 
  
        else 
  
            setElementModel ( thePed, 1 ) 
  
        end 
  
    end 
  
end 
  
  
  
function Left ( ) 
  
    if ( isElement ( thePed ) ) then 
  
        if ( getElementModel ( thePed ) ~= 1 ) then 
  
            setElementModel ( thePed, 1 ) 
  
        else 
  
            setElementModel ( thePed, 280 ) 
  
        end 
  
    end 
  
end 
  
  
  
addEventHandler ( "onClientGUIClick", root, 
  
    function ( ) 
  
        if ( source == SpawnBtn ) then 
  
            triggerServerEvent ( "spawnPed", localPlayer, getElementModel ( thePed ) ) 
  
            if isElement ( thePed ) then destroyElement ( thePed ) end 
  
            if isElement ( theObject ) then destroyElement ( theObject ) end 
  
            destroyElement ( SpawnBtn ) 
  
            destroyElement ( RightBtn ) 
  
            destroyElement ( LeftBtn ) 
  
            showCursor ( false ) 
  
        elseif ( source == RightBtn ) then 
  
            Right ( ) 
  
        elseif ( source == LeftBtn ) then 
  
            Left ( ) 
  
        end 
  
    end 
  
Link to comment

Try this :

 x, y = guiGetScreenSize ( ) 
function centerWindow ( center_window, k, v ) 
    local screenW, screenH = guiGetScreenSize ( ) 
    local windowW, windowH = guiGetSize ( center_window, false ) 
    local x, y = ( screenW - windowW ) / v, ( screenH - windowH )/k 
    guiSetPosition ( center_window, x, y, false ) 
end 
  
addEventHandler("onClientResourceStart",resourceRoot, function () 
sound = playSound("Alhajarii.mp3") 
end) 
  
thePed = createPed ( 1, 0, 0, 500, 90 ) 
setElementFrozen ( thePed, true ) 
setCameraMatrix ( -3.6658203125, 0, 500.48254455566, 2906.9938964844, 0, 201.84664916992 ) 
Animations = { "dnce_M_b"} 
setPedAnimation( thePed, "DANCING", Animations [ math.random ( #Animations ) ] ) 
theObject = createObject ( 1337, 0, 0, 499, 60 ) 
setElementAlpha ( theObject, 0 ) 
  
SpawnBtn = guiCreateButton( 0, 0, 125, 62.5, "Spawn", false ) 
centerWindow ( SpawnBtn, 1.2, 1.96 ) 
RightBtn = guiCreateButton( 0, 0, 70, 35, ">", false ) 
centerWindow ( RightBtn, 2, 1.4 ) 
LeftBtn = guiCreateButton( 0, 0, 70, 35, "<", false ) 
centerWindow ( LeftBtn, 2, 3.3 ) 
showCursor ( true ) 
  
  
  
function Right ( ) 
    if ( isElement ( thePed ) ) then 
        if ( getElementModel ( thePed ) ~= 280 ) then 
            setElementModel ( thePed, 280 ) 
        else 
            setElementModel ( thePed, 1 ) 
        end 
    end 
end 
  
  
  
function Left ( ) 
    if ( isElement ( thePed ) ) then 
        if ( getElementModel ( thePed ) ~= 1 ) then 
            setElementModel ( thePed, 1 ) 
        else 
            setElementModel ( thePed, 280 ) 
        end 
    end 
end 
  
  
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == SpawnBtn ) then 
            triggerServerEvent ( "spawnPed", localPlayer, getElementModel ( thePed ) ) 
            if isElement ( thePed ) then destroyElement ( thePed ) end 
            if isElement ( theObject ) then destroyElement ( theObject ) end 
            destroyElement ( SpawnBtn ) 
            destroyElement ( RightBtn ) 
            destroyElement ( LeftBtn ) 
           stopSound(sound) sound = nil 
            showCursor ( false ) 
        elseif ( source == RightBtn ) then 
            Right ( ) 
        elseif ( source == LeftBtn ) then 
            Left ( ) 
        end 
    end 
) 
  
Link to comment
Try this :

 x, y = guiGetScreenSize ( ) 
function centerWindow ( center_window, k, v ) 
    local screenW, screenH = guiGetScreenSize ( ) 
    local windowW, windowH = guiGetSize ( center_window, false ) 
    local x, y = ( screenW - windowW ) / v, ( screenH - windowH )/k 
    guiSetPosition ( center_window, x, y, false ) 
end 
  
addEventHandler("onClientResourceStart",resourceRoot, function () 
sound = playSound("AlooyFTW.mp3") 
end) 
  
thePed = createPed ( 1, 0, 0, 500, 90 ) 
setElementFrozen ( thePed, true ) 
setCameraMatrix ( -3.6658203125, 0, 500.48254455566, 2906.9938964844, 0, 201.84664916992 ) 
Animations = { "dnce_M_b"} 
setPedAnimation( thePed, "DANCING", Animations [ math.random ( #Animations ) ] ) 
theObject = createObject ( 1337, 0, 0, 499, 60 ) 
setElementAlpha ( theObject, 0 ) 
  
SpawnBtn = guiCreateButton( 0, 0, 125, 62.5, "Spawn", false ) 
centerWindow ( SpawnBtn, 1.2, 1.96 ) 
RightBtn = guiCreateButton( 0, 0, 70, 35, ">", false ) 
centerWindow ( RightBtn, 2, 1.4 ) 
LeftBtn = guiCreateButton( 0, 0, 70, 35, "<", false ) 
centerWindow ( LeftBtn, 2, 3.3 ) 
showCursor ( true ) 
  
  
  
function Right ( ) 
    if ( isElement ( thePed ) ) then 
        if ( getElementModel ( thePed ) ~= 280 ) then 
            setElementModel ( thePed, 280 ) 
        else 
            setElementModel ( thePed, 1 ) 
        end 
    end 
end 
  
  
  
function Left ( ) 
    if ( isElement ( thePed ) ) then 
        if ( getElementModel ( thePed ) ~= 1 ) then 
            setElementModel ( thePed, 1 ) 
        else 
            setElementModel ( thePed, 280 ) 
        end 
    end 
end 
  
  
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == SpawnBtn ) then 
            triggerServerEvent ( "spawnPed", localPlayer, getElementModel ( thePed ) ) 
            if isElement ( thePed ) then destroyElement ( thePed ) end 
            if isElement ( theObject ) then destroyElement ( theObject ) end 
            destroyElement ( SpawnBtn ) 
            destroyElement ( RightBtn ) 
            destroyElement ( LeftBtn ) 
           stopSound(sound) sound = nil 
            showCursor ( false ) 
        elseif ( source == RightBtn ) then 
            Right ( ) 
        elseif ( source == LeftBtn ) then 
            Left ( ) 
        end 
    end 
) 
  

still same proplem did't fixed

this is the meta

    
Link to comment
The problem is from you're server host -_- works good with me.

ok all think now fixed

but the spawn

mode

he is did't work cameraMatrix

when player join server did't

take the ped fly

+

the sound did't play

and

I want when player wasted the

spawn mode open for him to take team

Link to comment
The sound work's with me but i don't know what's the fuc k problem with you? and try to make it you're self the other what you ask me to do it.

how I do it ?

event "onPlayerWasted" 
triggerClientEvent 
-------------------------- 
event "onPlayerJoin" 
triggerClientEvent 
  
Link to comment

You didnt create a function with this

 thePed = createPed ( 1, 0, 0, 500, 90 ) 
setElementFrozen ( thePed, true ) 
setCameraMatrix ( -3.6658203125, 0, 500.48254455566, 2906.9938964844, 0, 201.84664916992 ) 
Animations = { "dnce_M_b"} 
setPedAnimation( thePed, "DANCING", Animations [ math.random ( #Animations ) ] ) 
theObject = createObject ( 1337, 0, 0, 499, 60 ) 
setElementAlpha ( theObject, 0 ) 
  
SpawnBtn = guiCreateButton( 0, 0, 125, 62.5, "Spawn", false ) 
centerWindow ( SpawnBtn, 1.2, 1.96 ) 
RightBtn = guiCreateButton( 0, 0, 70, 35, ">", false ) 
centerWindow ( RightBtn, 2, 1.4 ) 
LeftBtn = guiCreateButton( 0, 0, 70, 35, "<", false ) 
centerWindow ( LeftBtn, 2, 3.3 ) 
showCursor ( true )  

This should be:

function joinPlayer() 
thePed = createPed ( 1, 0, 0, 500, 90 ) 
setElementFrozen ( thePed, true ) 
setCameraMatrix ( -3.6658203125, 0, 500.48254455566, 2906.9938964844, 0, 201.84664916992 ) 
Animations = { "dnce_M_b"} 
setPedAnimation( thePed, "DANCING", Animations [ math.random ( #Animations ) ] ) 
theObject = createObject ( 1337, 0, 0, 499, 60 ) 
setElementAlpha ( theObject, 0 ) 
  
SpawnBtn = guiCreateButton( 0, 0, 125, 62.5, "Spawn", false ) 
centerWindow ( SpawnBtn, 1.2, 1.96 ) 
RightBtn = guiCreateButton( 0, 0, 70, 35, ">", false ) 
centerWindow ( RightBtn, 2, 1.4 ) 
LeftBtn = guiCreateButton( 0, 0, 70, 35, "<", false ) 
centerWindow ( LeftBtn, 2, 3.3 ) 
showCursor ( true )  
end 
addEventHandler("onClientPlayerJoin", getRootElement(), joinPlayer) 

Link to comment
You didnt create a function with this
 thePed = createPed ( 1, 0, 0, 500, 90 ) 
setElementFrozen ( thePed, true ) 
setCameraMatrix ( -3.6658203125, 0, 500.48254455566, 2906.9938964844, 0, 201.84664916992 ) 
Animations = { "dnce_M_b"} 
setPedAnimation( thePed, "DANCING", Animations [ math.random ( #Animations ) ] ) 
theObject = createObject ( 1337, 0, 0, 499, 60 ) 
setElementAlpha ( theObject, 0 ) 
  
SpawnBtn = guiCreateButton( 0, 0, 125, 62.5, "Spawn", false ) 
centerWindow ( SpawnBtn, 1.2, 1.96 ) 
RightBtn = guiCreateButton( 0, 0, 70, 35, ">", false ) 
centerWindow ( RightBtn, 2, 1.4 ) 
LeftBtn = guiCreateButton( 0, 0, 70, 35, "<", false ) 
centerWindow ( LeftBtn, 2, 3.3 ) 
showCursor ( true )  

This should be:

function joinPlayer() 
thePed = createPed ( 1, 0, 0, 500, 90 ) 
setElementFrozen ( thePed, true ) 
setCameraMatrix ( -3.6658203125, 0, 500.48254455566, 2906.9938964844, 0, 201.84664916992 ) 
Animations = { "dnce_M_b"} 
setPedAnimation( thePed, "DANCING", Animations [ math.random ( #Animations ) ] ) 
theObject = createObject ( 1337, 0, 0, 499, 60 ) 
setElementAlpha ( theObject, 0 ) 
  
SpawnBtn = guiCreateButton( 0, 0, 125, 62.5, "Spawn", false ) 
centerWindow ( SpawnBtn, 1.2, 1.96 ) 
RightBtn = guiCreateButton( 0, 0, 70, 35, ">", false ) 
centerWindow ( RightBtn, 2, 1.4 ) 
LeftBtn = guiCreateButton( 0, 0, 70, 35, "<", false ) 
centerWindow ( LeftBtn, 2, 3.3 ) 
showCursor ( true )  
end 
addEventHandler("onClientPlayerJoin", getRootElement(), joinPlayer) 

Or better use : onClientResourceStart and onClientPlayerWasted :wink:

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...