• 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] doPlayerKick(cid, storage, time, msg, pos)

Potar

SocialWorld
Senator
Joined
Mar 1, 2009
Messages
1,664
Reaction score
125
Location
Warsaw, Poland
Hello, I'm adding simple function to kick player, can be used for any raids, hunting rooms etc. I will also publish some scripts where I have used this function soon.

Lua:
function doPlayerKick(cid, storage, time, msg, pos)
	addEvent(
	function()
	if isCreature(cid) then
		if storage == 0 then
			doTeleportThing(cid, pos)
			doCreatureSay(cid, msg, TALKTYPE_ORANGE_1)
		else
			if getPlayerStorageValue(cid, storage) == 1 then
				doTeleportThing(cid, pos)
				doCreatureSay(cid, msg, TALKTYPE_ORANGE_1)
				doPlayerSetStorageValue(cid, storage, -1)
			end
		end
	end
		return true
	end,
	time
	)
	return true
end

Library:

- storage must be a number, 0 if you won't use storage (just a teleport after X sec).
- time must be a number, cannot be lower than 0 (0 if you want instant teleport).
- msg must be a string "Simple message" or 'Simple message'.
- pos must be a table, where player will be teleported after time {x = 0, y = 0, z = 0}.

Example:

doPlayerKick(cid, 30000, 6000, "You has been moved to jail cause of chargeback.", {x = 1000, y = 1000, z = 7})

Player with Storage 30000 and Value 1 will be moved after 6 sec to possition {x = 1000, y = 1000, z = 7}, He also will see a message "You has been moved to jail cause of chargeback.".

FAQ:

Why have you used storage?
- Becuse someone may want to check the player if already killed X monster or leaved area (For example you have 10 sec to kill rat if you won't do it you will be teleported if you will do it and you will also add creaturescripts onKill doPlayerSetStorageValue(cid, storage, -1) player won't be teleported, system will ignore him).
- There is also alternative way without storage ^_^, just write 0.

How time works here?
- Just a 1000 ms = 1 sec so if you want to kick after 10 sec you have to write 10000.

Why have you wrote it?
- As i said i have used it to some scripts, i was so lazy to write it same like 20 times.

How can i set the possition to teleport?
- Just use a table {x = 0, y = 0, z = 0}.

Why didn't you use a check value if it isn't nil and correct type()?
- Because I believe that you are not a monkey, and you will spend like 1 min to read info about it.

I know it is really easy to write, but i think it will be usefull.

Hope you like it ^_^.

Changelog:
- Added creature check isCreature(cid).
 
Last edited:
no creature check
player dies or logs out and
Code:
[19/06/2013 20:07:50] [Error - TalkAction Interface] 
[19/06/2013 20:07:50] In a timer event called from script: 
[19/06/2013 20:07:50] Description: 
[19/06/2013 20:07:50] (luaGetCreatureStorage) Creature not found
 
no creature check
player dies or logs out and
Code:
[19/06/2013 20:07:50] [Error - TalkAction Interface] 
[19/06/2013 20:07:50] In a timer event called from script: 
[19/06/2013 20:07:50] Description: 
[19/06/2013 20:07:50] (luaGetCreatureStorage) Creature not found

Yeah, I've added it on my script but I forgot to update it there.

Anyway done.
 
Last edited:
xD don't bother database, just use isCreature(cid)
 
Haha lol, that's true ^_^ sorry guys didnt sleep from exam like 30h :S so my brain is dead as you can see.

- - - Updated - - -

shouldn't be "you wrote it?" ?

Should be ^_^, just a word mistake.
 
Last edited:
Back
Top