Jump to content

Gm image


Recommended Posts

Posted

hey hello im here now because i have an autoghost mode for race gamemode and i want to put some images to see when the gm is on or when its off can u help me how to put the image functions?

there is the code i want to add 2 images 1 must be showing when gm is on and if gm is off it must shows another one... can someone help me?

gmontext = get("gmontext") 
gmoncolor = get("gmoncolor") 
gmofftext = get("gmofftext") 
gmoffcolor = get("gmoffcolor") 
  
addEvent("onMapStarting") 
addEventHandler("onMapStarting", getRootElement(), 
function(mapInfo) 
    if string.find(mapInfo.name, "[DM]", 1, true) or mapInfo.modename == "Sprint" then 
    gmon() 
        else 
    gmoff() 
    end 
end) 
function gmon() 
        for theKey,thePlayer in ipairs(getElementsByType("player")) do 
            setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false ) 
            outputChatBox(gmoncolor..gmontext,thePlayer,186,212,71,true) 
        end 
end 
function gmoff() 
        for theKey,thePlayer in ipairs(getElementsByType("player")) do 
            setElementData(thePlayer, "overrideCollide.uniqueblah", nil, false ) 
            outputChatBox(gmoffcolor..gmofftext,thePlayer,255,255,255,true) 
        end 
end 

Posted

1)sync the element data with clients, by changing last false to true in line 17 & 23

2)add in client script

  
x,y=guiGetScreenSize() 
localP=getLocalPlayer() 
  
addEventHandler("onClientRender",getRootElement(),function() 
  dxDrawImage (x-100,y-100,80,80,getElementData(localP,"overrideCollide.uniqueblah") and "on filepath" or "off filepath") --adjust height etc, dunno them, and put real image filepaths; this "isTrue and doIfTrue or doIfFalse" is short way of duing "if .. then x=a else x=b end". 
end) 
  

Posted

replace first 4arguments with position/size of image you need, according to wiki,(im my example image is created 100pixels from bottom right corner in both directions, and is 80pixel high and long) and then put those 2 filepaths at the end

for example if gmoff image is called "GMoff.png",

then put the image in same folder as this script,

and write "GMoff.png" in the filepath string

  
x,y=guiGetScreenSize() 
localP=getLocalPlayer() 
  
addEventHandler("onClientRender",getRootElement(),function() 
  dxDrawImage (x-100,y-100,80,80,getElementData(localP,"overrideCollide.uniqueblah") and "GMon.png" or "GMoff.png")  
end) 
  

Posted

plz give the example whit the whole script plz

the whole script wouldnt be an example already.

Posted

u mean this???

gmontext = get("gmontext") 
gmoncolor = get("gmoncolor") 
gmofftext = get("gmofftext") 
gmoffcolor = get("gmoffcolor") 
  
addEvent("onMapStarting") 
addEventHandler("onMapStarting", getRootElement(), 
function(mapInfo) 
    if string.find(mapInfo.name, "[DM]", 1, true) or mapInfo.modename == "Sprint" then 
    gmon() 
        else 
    gmoff() 
    end 
end) 
function gmon() 
        for theKey,thePlayer in ipairs(getElementsByType("player")) do 
x,y=guiGetScreenSize() 
localP=getLocalPlayer() 
  
addEventHandler("onClientRender",getRootElement(),function() 
  dxDrawImage (x-100,y-100,80,80,getElementData(localP,"overrideCollide.uniqueblah") and "GMon.png") 
end) 
            outputChatBox(gmoncolor..gmontext,thePlayer,186,212,71,true) 
        end 
end 
function gmoff() 
        for theKey,thePlayer in ipairs(getElementsByType("player")) do 
x,y=guiGetScreenSize() 
localP=getLocalPlayer() 
  
addEventHandler("onClientRender",getRootElement(),function() 
  dxDrawImage (x-100,y-100,80,80,getElementData(localP,"overrideCollide.uniqueblah") and "GMoff.png") 
end) 
            outputChatBox(gmoffcolor..gmofftext,thePlayer,255,255,255,true) 
        end 
end 

u mena that???

Posted

first, it have to be clientside.

second, it makes no sence how you put it together.

third, im helping you, but not going to make whole resource.

and yes, it draws off or on, depending on state of that element data.

Posted

srry for double post, all is working perfect but i have a problem now how i can make the image stay in the same place whit all resolutions?

Posted
srry for double post, all is working perfect but i have a problem now how i can make the image stay in the same place whit all resolutions?

say where you want it to be(how much pixels from what corner) and ill try to fix it.

Posted

there is the image line:

dxDrawImage (x-100,y-540,36,35,getElementData(localP,"overrideCollide.uniqueblah") and "ghostmodeon.png" or "ghostmodeoff.png") 

  • Moderators
Posted
there is the image line:
dxDrawImage (x-100,y-540,36,35,getElementData(localP,"overrideCollide.uniqueblah") and "ghostmodeon.png" or "ghostmodeoff.png") 

Just say us with what resolution the position is perfect, and I can make it :wink:

Posted

i just want to make when u change your resolution like 800x600x32 to 1024x1024x 32 it get in the same place cuz when i change it it appears in another place of screen over other script i have...

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