• 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!

[TalkAction]Outfit with effect & interval

Uffox

It's My Life
Joined
Aug 5, 2010
Messages
20
Reaction score
0
Location
Im Live In Mexico Why?
Hi guys i come to request a script.

More than a script I need a function that when you put that outfit you add an effect that comes out every 2 seconds when you change to another outfit remove you understand me?

pd: Sorry for my bad english i need to learn more xD
 
Last edited:
You can only bump once each 24 hours

your code would be something like this:

Code:
function doEffect(cid, outfit)
    if getCreatureOutfit(cid).looktype ~= outfit then
        return false
    end
    --Insert your effect here
    addEvent(doEffect, 2000, cid, outfit)
    return true
end

use this function on your creaturescript "onOutfit", should work fine, post here if it doesnt :)
 
You can only bump once each 24 hours

your code would be something like this:

Code:
function doEffect(cid, outfit)
    if getCreatureOutfit(cid).looktype ~= outfit then
        return false
    end
    --Insert your effect here
    addEvent(doEffect, 2000, cid, outfit)
    return true
end

use this function on your creaturescript "onOutfit", should work fine, post here if it doesnt :)

Lua:
local outfit, effect = 134, CONST_ME_FIREAREA
function onThink(interval, lastExecution, thinkInterval)
	for _, cid in ipairs(getPlayersOnline()) do
		if(getCreatureOutfit(cid).looktype == outfit) then
			doSendMagicEffect(getPlayerPosition(cid), effect)
		end
	end
	return true
end
 
He specifically asked for a function
Also, using the server onThink is a bad move imo, if you are gonna use the onThink, its better to use the player's own onThink, cause by using the server one you are always going thru all the players online which would generate more lag :)
 
He specifically asked for a function
Also, using the server onThink is a bad move imo, if you are gonna use the onThink, its better to use the player's own onThink, cause by using the server one you are always going thru all the players online which would generate more lag :)
only if the event is registered for all players
 
He specifically asked for a function
Also, using the server onThink is a bad move imo, if you are gonna use the onThink, its better to use the player's own onThink, cause by using the server one you are always going thru all the players online which would generate more lag :)

Actually its not lol.

only if the event is registered for all players

True.
 
if it isnt the server onThink why the hell are you searching for all online players?
if many players have that script registered, it'll make more effects then what is expected

if its for the player onThink, you should simply compare their own outfit with the one that sends the effect

also if that code is for players, where's the cid on the function? (i know the names can be changed, i dont think you'd call the creature id 'interval' lol)
 
if it isnt the server onThink why the hell are you searching for all online players?
if many players have that script registered, it'll make more effects then what is expected

if its for the player onThink, you should simply compare their own outfit with the one that sends the effect

also if that code is for players, where's the cid on the function? (i know the names can be changed, i dont think you'd call the creature id 'interval' lol)

Lua:
for _, cid in ipairs(getPlayersOnline()) do

Here.

And looping through all players with the usage of 1 code is more effective than using #getOnlinePlayers() codes.
 
I still think that that code is a server onThink function
yes, you have a cid there, but if this really is for the player onThink, shouldnt the function already give you a cid?
and if for some reason, this code really is for player onThink, this will show the effect for every player that has the outfit since your using a for to go thru all online players

if you really want a script for the player onThink, you should have used something like this:
Code:
local outfit, effect = 134, CONST_ME_FIREAREA
function onThink(cid, interval)    
    if(getCreatureOutfit(cid).looktype == outfit) then        
        doSendMagicEffect(getPlayerPosition(cid), effect)    
    end    
    return true
end
 
I still think that that code is a server onThink function
yes, you have a cid there, but if this really is for the player onThink, shouldnt the function already give you a cid?
and if for some reason, this code really is for player onThink, this will show the effect for every player that has the outfit since your using a for to go thru all online players

if you really want a script for the player onThink, you should have used something like this:
Code:
local outfit, effect = 134, CONST_ME_FIREAREA
function onThink(cid, interval)    
    if(getCreatureOutfit(cid).looktype == outfit) then        
        doSendMagicEffect(getPlayerPosition(cid), effect)    
    end    
    return true
end

You don't understand, my script is not registered for every player that is online. It executes itself only one time per interval!
 
if it only executes itself one time per interval its a server onThink, not a player onThink :p


server onThink(global events): runs once every X time
player onThink(creature events): runs once every X time for registered players (already gives the player that the script is running for)


I still think the player onThink is better since you don't have to go thru the entire player list, but this is purely personal opinion, both ways would work :)
 
if it only executes itself one time per interval its a server onThink, not a player onThink :p


server onThink(global events): runs once every X time
player onThink(creature events): runs once every X time for registered players (already gives the player that the script is running for)


I still think the player onThink is better since you don't have to go thru the entire player list, but this is purely personal opinion, both ways would work :)

Yea, either one should work and there should be no apparent difference in the use of RAM. :)
 
not in RAM usage, no, but the CPU would be busy going thru all the online players while it could be doing something else

not sure about how OTServers deal with Multi-Threading, so I might be wrong :p

@Up
Yeah :)
 
Ameteurs... Use onOutfit() function that will call either registerCreatureEvent() or unregisterCreatureEvent() depending if you take on or off the outfit and then use creaturescript's onThink. The script will only execute on those who changed to certain outfit. Kthxbye, I'm outta here ;].
 
Back
Top