Need help making a simple script. What am I doing wrong?

I’m trying to make a script where if a player is wanted, he/she is sent to jail when he/she is killed. Am I doing something wrong?


WantedDeathMessage = "You have been arrested upon death due to your wanted status." 

function GM:PlayerDeath( victim, inflictor, attacker )
	if 	victim:isWanted() then
		victim:Arrest()
		victim:PrintMessage( HUD_PRINTCENTER, ..WantedDeathMessage.. )
	end
end

Get rid of the double dots you put next to the printmessage thing and it would probably work (Lua expects those dots when a string is meant to be conjoined, e.g. ‘dog’…‘ass’ > ‘dogass’)

[editline]26th February 2016[/editline]

Also, you might want to put that in a hook so it doesn’t override the core PlayerDeath function like so:



local WantedDeathMessage = "You have been arrested upon death due to your wanted status." 

hook.Add( 'PlayerDeath', 'ArrestDeadPlayers', function( victim, inflictor, attacker )
	if victim:isWanted() then
		victim:Arrest()
		victim:PrintMessage( HUD_PRINTCENTER, WantedDeathMessage )
	end
end )


[editline]26th February 2016[/editline]

I haven’t tested that though, so it might not work

Hmm, I tried putting that in and it still doesn’t seem to work. Any other ideas on why it might not be working? Also, am I putting it in the right folder? garrysmod/lua/autorun

Are you sure victim:isWanted has a lower-case ‘i’?

I’m pretty sure it does. I used this, not sure if it was changed or anything.
http://wiki.darkrp.com/index.php/Functions/Player/Shared/isWanted

Am I using the wrong one? Is it this one I am supposed to use?
http://wiki.darkrp.com/index.php/Hooks/Server/playerWanted

If you didn’t get errors with that first piece of code you had then it’s not running, post the exact file path

I tried putting in garrysmod/lua/autorun and garrysmod/lua/autorun/server. Both didn’t work, where should I put it?

What is the file called?

It is called arrest.lua and is a lua file.