Jump to content

Help my script


Flipi

Recommended Posts

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" 
    /> 

Link to comment
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. 

Link to comment
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

Link to comment
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?

Link to comment

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" />>

Link to comment
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:

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