Jump to content

help


Paplo

Recommended Posts

I made 3 images

i want

if click in image 1 = start gamemode 1 + stop gamemode 2 + stopgame mode3

else click in image 2 = start gamemode 2 + stop gamemode 1 + stop gamemode3

else click in image 3 = start gamemode 3 + stop gamemode 1 + stop gamemode 2

how can be this ?

help plz :roll:

Link to comment

i have 3 gamemode ( race , play , fallout )

i made 3 images

i want

if press in first image start gamemode race and stop gamemode play,fallout

else press in image 2 start gamemode play and stop gamemode race,fallout

else press in image 3 start gamemide fallout and stop gamemode race,play

Note I want to stop gamemode when the player himself and not for the entire server

Link to comment
i have 3 gamemode ( race , play , fallout )

i made 3 images

i want

if press in first image start gamemode race and stop gamemode play,fallout

else press in image 2 start gamemode play and stop gamemode race,fallout

else press in image 3 start gamemide fallout and stop gamemode race,play

Note I want to stop gamemode when the player himself and not for the entire server

Use :

setElementData 

And edit the gamemode when the player start play ^^

Link to comment
i have 3 gamemode ( race , play , fallout )

i made 3 images

i want

if press in first image start gamemode race and stop gamemode play,fallout

else press in image 2 start gamemode play and stop gamemode race,fallout

else press in image 3 start gamemide fallout and stop gamemode race,play

Note I want to stop gamemode when the player himself and not for the entire server

Use :

setElementData 

And edit the gamemode when the player start play ^^

Can you give me an example!

Link to comment
i have 3 gamemode ( race , play , fallout )

i made 3 images

i want

if press in first image start gamemode race and stop gamemode play,fallout

else press in image 2 start gamemode play and stop gamemode race,fallout

else press in image 3 start gamemide fallout and stop gamemode race,play

Note I want to stop gamemode when the player himself and not for the entire server

Use :

setElementData 

And edit the gamemode when the player start play ^^

Can you give me an example!

it,s hard to give an example but should to be like that :

setElementData(localPlayer, "FallOut", false) 

function activateFreeCam(status) 
if getElementData(localPlayer, "Race") or getElementData(localPlayer, "Play") then 
 return  
  end 
if getElementData(localPlayer, "FallOut") then 
-- Complete the play function ... 

For each gamemode you should to use getElementData And SetElementData ! And Edit the gameMode when the player start play!

Link to comment
function activateFreeCam(status) 
if getElementData(localPlayer, "Race") or getElementData(localPlayer, "Play") then 
 return  
  end 
if getElementData(localPlayer, "FallOut") then 
-- Complete the play function ... 

For each gamemode you should to use getElementData And SetElementData ! And Edit the gameMode when the player start play!

function activateFreeCam(status) 
if getElementData(localPlayer, "Race") or getElementData(localPlayer, "Play") then 
 return 
  end 
if getElementData(localPlayer, "FallOut") then 
    fadeCamera ( true ) --Remove MTA fade 
gameOver = false 
local shakingPieces = {} 
  
function shakeOnRender() 
    if gameOver == false then 
        local currentTick = getTickCount() 
        for object,originalTick in pairs(shakingPieces) do 
            --calculate the amount of time that has passed in ms 
            local tickDifference = currentTick - originalTick 
            --if the time has exceeded its max 
            if tickDifference > 2400 then 
                shakingPieces[object] = nil --remove it from the table loop 
            else 
                --since newx/newy increases by 1 every 125ms, we can use this ratio to calculate a more accurate time 
                local newx = tickDifference/125 * 1 
                local newy = tickDifference/125 * 1 
                if isElement ( object ) then 
                    setElementRotation ( object, math.deg( 0.555 ), 3 * math.cos(newy + 1), 3 * math.sin(newx + 1) ) 
                end 
            end 
        end 
    end 
end 
addEventHandler ( "onClientRender", getRootElement(), shakeOnRender ) 
  
function ShakePieces ( fallingPiece ) 
        --we store the time when the piece was told to shake under a table, so multiple objects can be stored 
        shakingPieces[fallingPiece] = getTickCount() 
end 
addEvent("clientShakePieces",true) --For triggering from server 
addEventHandler("clientShakePieces", getRootElement(), ShakePieces) 
  
function DetectionOff ( fallingPiece ) 
    checkStatusTimer = nil 
    gameOver = true 
end 
addEvent("lossDetectionOff",true) --For triggering from server 
addEventHandler("lossDetectionOff", getRootElement(), DetectionOff) 
  
function checkStatusB ( ) 
    local x, y, z =  getElementPosition ( localPlayer ) 
    if z < 595 and ( checkStatusTimer ) then 
        --RootElement as localPlayer = source in server event 
        triggerServerEvent ( "serverReportLoss", localPlayer ) 
        playSoundFrontEnd(4) 
        --outputChatBox ( "**************loss report**************" ) --DEBUG--DEBUG--DEBUG--DEBUG--DEBUG 
        killTimer ( checkStatusTimer ) 
        checkStatusTimer = nil 
    end 
end  
  
function checkHax ( ) 
    weapon = getPedWeapon ( localPlayer ) --anti cheat protection 
    if weapon ~= 0 then 
        setPedWeaponSlot ( localPlayer, 0 ) 
        triggerServerEvent ( "serverKillCheater", localPlayer ) 
    end 
end 
setTimer ( checkHax, 1000, 0 ) 
  
function checkStatus ( ) 
    gameOver = false --Reset as this is new game time 
    checkStatusTimer = setTimer ( checkStatusB, 500, 0 )                  
    end end) 
addEvent("clientCheckStatus",true) --For triggering from server 
addEventHandler("clientCheckStatus", getRootElement(), checkStatus) 
     

lol !

Link to comment

Wrong! open freecamclient.lua then do that :

addEventHandler("onClientResourceStart", resourceRoot, freecamLoad) 
function activateFreeCam(status) 
  if getElementData(localPlayer, "Race") or getElementData(localPlayer, "Play") then 
 return  
  end 
  if getElementData(localPlayer, "FallOut") then 
    spectateActivated = status 
  end 
  if status == false then 
    setCameraTarget(localPlayer) 
  end 
end 

And i hope you setElementData From the Main File The File To Play GameModes OnClick. And You Should to trigger the data .

Link to comment

That will take ages to write if you have much gamemodes. Easier way will be to use element data "gm" or "mode" ( whatever you want ) which stores a string/number or any other thing that represents each gamemode and use events to show things for a specific guy.

Example:

--For getting player gamemode ( idea from NPG ): 
local gamemodes =  
{  
    [1] = "Play", 
    [2] = "Fallout", 
    [3] = "Race" 
} 
  
--will return mode number ( shown in array as indexes ) or 0 if arguments are invalid 
function getPlayerGamemode ( player ) 
    if ( isElement ( player ) and getElementType ( player ) == 'player' ) then 
        return getElementData ( player, "mode" ); 
    end 
    return 0 
end 
  
--will return true if player gamemode was set sucessfully, false otherwise 
function setPlayerGamemode ( player, mode ) 
    if ( ( isElement ( player ) and getElementType ( player ) == 'player' ) and ( type ( mode ) == 'number' ) ) then 
        return setElementData ( player, "mode", mode ); 
    end 
end 
  
--For gamemode start: 
  
--Call the above function to set player element data "mode" and then add the event and a handler for it in a core resource and in the function of the event check if the mode exists, if it does, set player element data "mode" to the new mode. You should then add "onPlayerGamemodeJoin" / "onClientPlayerGamemodeJoin" in your gamemode resource and check if the player ( can be source, if you specify it in trigger functions ) is the local player 
  
addEvent ( "onPlayerGamemodeJoin", true ); 
addEventHandler ( "onPlayerGamemodeJoin", root, 
    function ( mode ) 
        for k,v in ipairs ( getElementsByType ( "player" ) ) do 
            if ( v == source ) then 
                if ( mode == thisModeID ) then 
                    --load things for source 
                end 
            end 
        end 
    end 
) 
  
--NOTE: firstly you should set element data "mode" to 0 when players joins the server, 
--when the player joins a gamemode u set his element data to the mode he just entered 

Hope you understand what I tried to explain above, didn't know exactly how to say it.

Link to comment
That will take ages to write if you have much gamemodes. Easier way will be to use element data "gm" or "mode" ( whatever you want ) which stores a string/number or any other thing that represents each gamemode and use events to show things for a specific guy.

Example:

--For getting player gamemode ( idea from NPG ): 
local gamemodes =  
{  
    [1] = "Play", 
    [2] = "Fallout", 
    [3] = "Race" 
} 
  
--will return mode number ( shown in array as indexes ) or 0 if arguments are invalid 
function getPlayerGamemode ( player ) 
    if ( isElement ( player ) and getElementType ( player ) == 'player' ) then 
        return getElementData ( player, "mode" ); 
    end 
    return 0 
end 
  
--will return true if player gamemode was set sucessfully, false otherwise 
function setPlayerGamemode ( player, mode ) 
    if ( ( isElement ( player ) and getElementType ( player ) == 'player' ) and ( type ( mode ) == 'number' ) ) then 
        return setElementData ( player, "mode", mode ); 
    end 
end 
  
--For gamemode start: 
  
--Call the above function to set player element data "mode" and then add the event and a handler for it in a core resource and in the function of the event check if the mode exists, if it does, set player element data "mode" to the new mode. You should then add "onPlayerGamemodeJoin" / "onClientPlayerGamemodeJoin" in your gamemode resource and check if the player ( can be source, if you specify it in trigger functions ) is the local player 
  
addEvent ( "onPlayerGamemodeJoin", true ); 
addEventHandler ( "onPlayerGamemodeJoin", root, 
    function ( mode ) 
        for k,v in ipairs ( getElementsByType ( "player" ) ) do 
            if ( v == source ) then 
                if ( mode == thisModeID ) then 
                    --load things for source 
                end 
            end 
        end 
    end 
) 
  
--NOTE: firstly you should set element data "mode" to 0 when players joins the server, 
--when the player joins a gamemode u set his element data to the mode he just entered 

Hope you understand what I tried to explain above, didn't know exactly how to say it.

  
SERVER SIDE 
  
--For getting player gamemode ( idea from NPG ): 
local gamemodes = 
{ 
    [1] = "Play", 
    [2] = "Fallout", 
    [3] = "Race" 
} 
  
--will return mode number ( shown in array as indexes ) or 0 if arguments are invalid 
function getPlayerGamemode ( player ) 
    if ( isElement ( player ) and getElementType ( player ) == 'player' ) then 
        return getElementData ( player, "Fallout" ); 
    end 
    return 0 
end 
  
--will return true if player gamemode was set sucessfully, false otherwise 
function setPlayerGamemode ( player, Fallout ) 
    if ( ( isElement ( player ) and getElementType ( player ) == 'player' ) and ( type ( Fallout ) == 'number' ) ) then 
        return setElementData ( player, "Fallout", Fallout ); 
    end 
end 
  
--For gamemode start: 
  
--Call the above function to set player element data "mode" and then add the event and a handler for it in a core resource and in the function of the event check if the mode exists, if it does, set player element data "mode" to the new mode. You should then add "onPlayerGamemodeJoin" / "onClientPlayerGamemodeJoin" in your gamemode resource and check if the player ( can be source, if you specify it in trigger functions ) is the local player 
  
addEvent ( "onPlayerGamemodeJoin", true ); 
addEventHandler ( "onPlayerGamemodeJoin", root, 
    function ( Fallout ) 
        for k,v in ipairs ( getElementsByType ( "player" ) ) do 
            if ( v == source ) then 
                if ( Fallout == 2 ) then 
                    --load things for source 
                end 
            end 
        end 
    end 
) 
  
--NOTE: firstly you should set element data "mode" to 0 when players joins the server, 
--when the player joins a gamemode u set his element data to the mode he just entered 

  
CLIENT side 
  if (source == GUIEditor_Button[1]) then 
    triggerServerEvent ("onPlayerGamemodeJoin", getLocalPlayer())  
    guiSetVisible(GUIEditor_Window[1],false) 
        showCursor (false) 

If an error can you give me an example of Fallout

Link to comment
That will take ages to write if you have much gamemodes. Easier way will be to use element data "gm" or "mode" ( whatever you want ) which stores a string/number or any other thing that represents each gamemode and use events to show things for a specific guy.

Example:

--For getting player gamemode ( idea from NPG ): 
local gamemodes =  
{  
    [1] = "Play", 
    [2] = "Fallout", 
    [3] = "Race" 
} 
  
--will return mode number ( shown in array as indexes ) or 0 if arguments are invalid 
function getPlayerGamemode ( player ) 
    if ( isElement ( player ) and getElementType ( player ) == 'player' ) then 
        return getElementData ( player, "mode" ); 
    end 
    return 0 
end 
  
--will return true if player gamemode was set sucessfully, false otherwise 
function setPlayerGamemode ( player, mode ) 
    if ( ( isElement ( player ) and getElementType ( player ) == 'player' ) and ( type ( mode ) == 'number' ) ) then 
        return setElementData ( player, "mode", mode ); 
    end 
end 
  
--For gamemode start: 
  
--Call the above function to set player element data "mode" and then add the event and a handler for it in a core resource and in the function of the event check if the mode exists, if it does, set player element data "mode" to the new mode. You should then add "onPlayerGamemodeJoin" / "onClientPlayerGamemodeJoin" in your gamemode resource and check if the player ( can be source, if you specify it in trigger functions ) is the local player 
  
addEvent ( "onPlayerGamemodeJoin", true ); 
addEventHandler ( "onPlayerGamemodeJoin", root, 
    function ( mode ) 
        for k,v in ipairs ( getElementsByType ( "player" ) ) do 
            if ( v == source ) then 
                if ( mode == thisModeID ) then 
                    --load things for source 
                end 
            end 
        end 
    end 
) 
  
--NOTE: firstly you should set element data "mode" to 0 when players joins the server, 
--when the player joins a gamemode u set his element data to the mode he just entered 

Hope you understand what I tried to explain above, didn't know exactly how to say it.

  
SERVER SIDE 
  
--For getting player gamemode ( idea from NPG ): 
local gamemodes = 
{ 
    [1] = "Play", 
    [2] = "Fallout", 
    [3] = "Race" 
} 
  
--will return mode number ( shown in array as indexes ) or 0 if arguments are invalid 
function getPlayerGamemode ( player ) 
    if ( isElement ( player ) and getElementType ( player ) == 'player' ) then 
        return getElementData ( player, "Fallout" ); 
    end 
    return 0 
end 
  
--will return true if player gamemode was set sucessfully, false otherwise 
function setPlayerGamemode ( player, Fallout ) 
    if ( ( isElement ( player ) and getElementType ( player ) == 'player' ) and ( type ( Fallout ) == 'number' ) ) then 
        return setElementData ( player, "Fallout", Fallout ); 
    end 
end 
  
--For gamemode start: 
  
--Call the above function to set player element data "mode" and then add the event and a handler for it in a core resource and in the function of the event check if the mode exists, if it does, set player element data "mode" to the new mode. You should then add "onPlayerGamemodeJoin" / "onClientPlayerGamemodeJoin" in your gamemode resource and check if the player ( can be source, if you specify it in trigger functions ) is the local player 
  
addEvent ( "onPlayerGamemodeJoin", true ); 
addEventHandler ( "onPlayerGamemodeJoin", root, 
    function ( Fallout ) 
        for k,v in ipairs ( getElementsByType ( "player" ) ) do 
            if ( v == source ) then 
                if ( Fallout == 2 ) then 
                    --load things for source 
                end 
            end 
        end 
    end 
) 
  
--NOTE: firstly you should set element data "mode" to 0 when players joins the server, 
--when the player joins a gamemode u set his element data to the mode he just entered 

  
CLIENT side 
  if (source == GUIEditor_Button[1]) then 
    triggerServerEvent ("onPlayerGamemodeJoin", getLocalPlayer())  
    guiSetVisible(GUIEditor_Window[1],false) 
        showCursor (false) 

If an error can you give me an example of Fallout

All this wrong!Where is the data and you should to edit the gamemode as what i say in my post . A Simple examplie :

for FallOut :

Open Main File For You,re GameMode that one you want to create it ^^ . then this is what should to do :

GUIEditor = { 
staticimage = {}} 
  
  
  
FallOut = guiCreateStaticImage(0.0.0, 0, "Fallout.png", false ) 
  
setElementData(localPlayer, "FallOut", false) 
  
-- Complete function will not do for you everything 

then open the file when the player start play and the file in fallout gammode is : freecamclient.lua

You should to edit it like that ^^ :

addEventHandler("onClientResourceStart", resourceRoot, freecamLoad) 
 function activateFreeCam(status) 
  if getElementData(localPlayer, "Race") or getElementData(localPlayer, "Play") then 
    return  
  end 
  if getElementData(localPlayer, "FallOut") then 
    spectateActivated = status 
  end 
  if status == false then 
    setCameraTarget(localPlayer) 
  end 
end 

i hope you understand what i mean and you should to complete script yourself .

Link to comment

My code wasn't made for you to come here and copy + paste in your resource. It's an example of how to do that, and you need to script everything by yourself. That example is to explain you how to do it, just that.

@Mr.Pres[T]ege, your example is much harder/slower to write than mine, and I'd not recommend using too much element data.

Link to comment
My code wasn't made for you to come here and copy + paste in your resource. It's an example of how to do that, and you need to script everything by yourself. That example is to explain you how to do it, just that.

@Mr.Pres[T]ege, your example is much harder/slower to write than mine, and I'd not recommend using too much element data.

I know this, but I do not understand your code Thanks anyway!

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