• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Have i done this lua code right?

Mithaz

Nightimp Mapper/Scripter
Joined
Nov 7, 2007
Messages
120
Reaction score
1
Location
Sweden
Hello i have made a jail script.
How i shold work :

When the player has killed more than 6 players he shold be teleported to the jail position and then a broadcast is casted to notify others that a player has been jailed.

Lua:
local amount = getPlayerRedSkullTicks(cid)
local JailPos { x, y, z}
local playerName = getCreatureName(cid)
local Text = " has been sent to jail. The reason is too many unjustify kills!"

function onKill(cid, isPlayer(cid))
	if(amount > 6) then
	{
		
		doBroadcastMessage( playerName + Text );
		doTeleportThing( cid, jailpos );
		
	}
	end
end

Im a big noob on lua right now.
But in my opinion is that trying is the best way to learn to code.

So is this script going to work or have i done everything wrong? :D
 
you are using the wrong operators, the + is for concentanting strings in C++ not in lua the right operator is "..."
 
I think you should read some tutorials, LUA is different than C++, you use wrong functions and you should only use brackets in arrays.
I suggest you to read evil hero's tutorial.
 
It won't work because of a lot of things. Keep trying though.

Code:
local frags = 6
local jail = {x = 100, y = 100, z = 7}
function onKill(cid, target)
	if(isPlayer(cid) and isPlayer(target)) then
		if(getCreatureSkullType(target) <= 0 then
			if(getPlayerFrags(cid) > frags) then
				doTeleportThing(cid, jail, false)
				doBroadcastMessage(getCreatureName(cid) .. " has been sent to jail for too many unjustified kills.", MESSAGE_STATUS_WARNING)
			end
		end
	end
	
	return true
end
 
Thanks alot for all the help! Going to read that tutoral/guide and when im done i going to test to script my ideas again :D
 
Back
Top