Jump to content

Help my script


Flipi

Recommended Posts

Posted

How do I run the setting of my script? (the script is a shout admin)

Server-side

function shout( player, cmd, ... ) 
    local accountname = getAccountName( getPlayerAccount( player ) ) 
    local w = {...} 
    local message = table.concat(w, " ") 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) )  then 
        triggerClientEvent ( root, "onShouts", root, message ) 
            if get ("ColorText") then 
             dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) 
    else 
        outputChatBox( "* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true ) 
    end 
end 
end 
addCommandHandler( "shout", shout ) 

Client

local sx, sy = guiGetScreenSize() 
local sx = sx / 2 
local sy = sy / 2 
function drawText() 
    local width = dxGetTextWidth(theText, 3, "default") 
    local height = dxGetFontHeight(3, "default") 
    local leftB = sx - width / 2 
    local topB = sy - (height + 5) 
    local left = sx - width / 2 
    local top = sy - height 
    local ColorText = "#0080FF" 
    dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) 
    dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) 
end 
draw = false 
function drawShout(text) 
    if not draw then 
        theText = text 
        addEventHandler("onClientRender", root, drawText) 
        draw = true 
        setTimer(function() 
        draw = false 
        removeEventHandler("onClientRender", root, drawText) 
        end, 5000, 1) 
    end 
end 
addEvent("onShouts", true) 
addEventHandler("onShouts", root, drawShout) 

Meta setting

        name="*Colortexto" 
    value="#0080FF" 
    /> 

Posted

why don't you just color the name when he shouts, why do you have to make a settings for it?

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

Posted
why don't you just color the name when he shouts, why do you have to make a settings for it?

but as I can make it change color with the setting?

Posted

uhm yes you could afaik, but its more complicated better to do it from the main files.

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

Posted
dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) 

dx functions can't be executed serverside. Won't work.

Use triggerClientEvent to trigger some custom event and execute drawShout. This will work.

triggerClientEvent -- send the text as an argument. Should be executed serverside 
addEventHandler("onShouts", root, drawShout) -- You have this one. It's okay. Trigger it. 

Posted
dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) 

dx functions can't be executed serverside. Won't work.

Use triggerClientEvent to trigger some custom event and execute drawShout. This will work.

triggerClientEvent -- send the text as an argument. Should be executed serverside 
addEventHandler("onShouts", root, drawShout) -- You have this one. It's okay. Trigger it. 

help me add it to my script?, I'm confused :P

Posted

since the dxDraw functions are only clientsided and has to be used with onClientRender You should add a new event and trigger it. Add a new eventHandler which would display what you want. Making this command client-sided would even be alot easier.

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

Posted
since the dxDraw functions are only clientsided and has to be used with onClientRender You should add a new event and trigger it. Add a new eventHandler which would display what you want. Making this command client-sided would even be alot easier.

then remove the dxtext of server-side and added a new event in client-side?

in where part the client?

some example?

Posted

Client Side:

local sx, sy = guiGetScreenSize() 
local sx = sx/2 
local sy = sy/2 
function drawText() 
    local width = dxGetTextWidth(theText, 3, "default") 
    local height = dxGetFontHeight(3, "default") 
    local leftB = sx - width/2 
    local topB = sy - (height + 5) 
    local left = sx - width/2 
    local top = sy - height 
    dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) 
    dxDrawText(ColorText..theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) 
end 
  
function drawShout(text, color) 
    if not isTimer(drawTimer) and text and color then 
        addEventHandler("onClientRender", root, drawText) 
        theText = text 
        ColorText = color 
        drawTimer = setTimer(function() 
            removeEventHandler("onClientRender", root, drawText) 
        end, 5000, 1) 
    end 
end 
addEvent("onShouts", true) 
addEventHandler("onShouts", root, drawShout) 

Server Side:

function shout(player, cmd, ...) 
    local accountName = getAccountName(getPlayerAccount(player)) 
    local message = table.concat({...}, " ") 
    if isObjectInACLGroup("user."..accountName, aclGetGroup("Admin"))  then 
        triggerClientEvent(root, "onShouts", root, message, get("ColorText")) 
    else 
        outputChatBox("* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("shout", shout) 

Meta setting:

>    name="*ColorText" value="#0080FF" />>

CiTLh.png
Posted
Client Side:
local sx, sy = guiGetScreenSize() 
local sx = sx/2 
local sy = sy/2 
function drawText() 
    local width = dxGetTextWidth(theText, 3, "default") 
    local height = dxGetFontHeight(3, "default") 
    local leftB = sx - width/2 
    local topB = sy - (height + 5) 
    local left = sx - width/2 
    local top = sy - height 
    dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) 
    dxDrawText(ColorText..theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) 
end 
  
function drawShout(text, color) 
    if not isTimer(drawTimer) and text and color then 
        addEventHandler("onClientRender", root, drawText) 
        theText = text 
        ColorText = color 
        drawTimer = setTimer(function() 
            removeEventHandler("onClientRender", root, drawText) 
        end, 5000, 1) 
    end 
end 
addEvent("onShouts", true) 
addEventHandler("onShouts", root, drawShout) 

Server Side:

function shout(player, cmd, ...) 
    local accountName = getAccountName(getPlayerAccount(player)) 
    local message = table.concat({...}, " ") 
    if isObjectInACLGroup("user."..accountName, aclGetGroup("Admin"))  then 
        triggerClientEvent(root, "onShouts", root, message, get("ColorText")) 
    else 
        outputChatBox("* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("shout", shout) 

Meta setting:

>    name="*ColorText" value="#0080FF" />>

oh thanks :D, I added some font sizes! c:

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