i Want to make a Custom Command when i write on the chat:
!cash <PlayerName>
this print on the chat the amount of the player that he has.
something like this
<PlayerName> Has <Amount >$
but this is print only to the player that did the command.
Advance Thanks to Helpers !
I try do do that but it doesnt work
GM/PlayerSay
use network to send a message to the client when this hook gets called, and then use that network to let a chat message be printed on the players chat using chat.AddText
i make this one
how can i make that when i do !cash this is print the play amout of money
beacuse this is doesn't work
hook.Add( "PlayerSay","cash", function(ply, text, team)
if string.sub(text,0,8) == "!cash" then
ply:ChatPrint( ply:Nick().." has "..ply:GetMoney().."$" )
end
end
end)
what now how i continue ?
You're using string.sub from positions 0 to 8, but the message isn't even 8 characters long. Also, string postilions start from 1 in Lua. Really, you should just check:
if (string.lower(text) == "!cash") then
ok but how can i make that when someone type:
!cash bluzer
and it is print my amount of money
and when i type:
!cash <Name Of Someone>
and it is print the amount of his money
how can i make it ?
You can use either use string.match with string patterns to extract the name and command, or use string.Explode (check the example on that page).
Sorry, you need to Log In to post a reply to this thread.