Jump to content

Alert Strip


CallumD

Recommended Posts

I made some random strip along the bottom of every players screen using a GUI Window. I know how to change the text when an event is triggered but I don't get how to output the players name. Say for example I wanted to make it say " has died!" how would I get ? Because GUI is client-side if I use getLocalPlayer it just say to each player their own nick. How would I get a certain players name then make it work on the client-side script?

Link to comment
outputChatBox ( name.. " has a god damn " ..weapon, getRootElement(), 255, 100, 0 )

lolz

I think you should learn how to help first.

CallumD, show us your code. There are events that are triggered for every client (with source of remote player). You can use one of them or make your own and pass the remote player in triggerEvent or triggerClientEvent.

Link to comment

I wrote this off top. In the meantime I guess you can try this.

server script

function randomFunctionName ( ammo, killer, weapon, bodypart )
triggerClientEvent ( "server_PlayerDied", killer, getPlayerName(killer), getPlayerName(source) )
end
 
addEventHandler ( "onPlayerWasted", getRootElement(), randomFunctionName )

client script

addEvent ( "server_PlayerDied", true )
 
local delay = 2500
 
addEventHandler ( "server_PlayerDied", getRootElement(),
function ( killerName, victimName )
guiSetText ( whateverYourTextElementInYourGuiWindowIsCalled, tostring(victimName).. " has died!" )
setTimer ( guiSetText, delay, 1, whateverYourTextElementInYourGuiWindowIsCalled, "" )
end
)

Link to comment
I wrote this off top. In the meantime I guess you can try this.

server script

function randomFunctionName ( ammo, killer, weapon, bodypart )
triggerClientEvent ( "server_PlayerDied", killer, getPlayerName(killer), getPlayerName(source) )
end
 
addEventHandler ( "onPlayerWasted", getRootElement(), randomFunctionName )

client script

addEvent ( "server_PlayerDied", true )
 
local delay = 2500
 
addEventHandler ( "server_PlayerDied", getRootElement(),
function ( killerName, victimName )
guiSetText ( whateverYourTextElementInYourGuiWindowIsCalled, tostring(victimName).. " has died!" )
setTimer ( guiSetText, delay, 1, whateverYourTextElementInYourGuiWindowIsCalled, "" )
end
)

Why did you use server-side event and triggerClientEvent when you have the same event client-side

https://wiki.multitheftauto.com/wiki/OnC ... ayerWasted (read the description at the top)

Link to comment
Because client-side there is no syntax to get the player name (as far as I know of) and show it to all players without it just showing their own name.

What getPlayerName function does? Hmm, I don't know, do you? And if you could read what I say you'd know what onClientPlayerWasted is.

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