WiKi Examples - Moderation?!
#9

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by [XAC
Klinsen ]
Quote:
Originally Posted by Kyosaur!!
Quote:
Originally Posted by dice7
Pawn, as you mentioned, is static so variable creation starts at compile time, not run time, so you never use up more then those 720 bytes. And OnPlayerUpdate was introduced especially for creating custom accurate callbacks like that, why else would you possibly need it ? You have timers for tick functions and GetTickCount() for accurate time tests, etc.. And run a few test in term of memory usage and amx size, when dealing with local and global variables
nice way of putting it. I have a custom OnVirtualWorldChange callback that is pretty much coded the same as the article in question (well, what i mean is i create a variable / assign a value to said variable under OnPlayerUpdate), and i never thought twice about it as i'm content with using a SUPER small amount of ram (we're not even talking about 1kb lol) in order to accurately tell when a player is switching vw / have complete control over it; as vw is a big part of my server.

well, you actually could make that thing even without OnPlayerUpdate, as you just need to call the "OnVirtualWorldChange" if the players is set into a new virtual world, which MUST be done via "SetPlayerVirtualWorld", right?

So you could just make a thing like this:
pawn Код:
#define SetVirtualWorld(%1,%2) SetPlayerVirtualWorld(%1,%2); SetPVarInt(%1,"vworld",%2); OnVirtualWorldChange(%1,%2)

public OnVirtualWorldChange(playerid, virtualworld) {
// etc
}
Now you would just need to replace each "SetPlayerVirtualWorld" (except the one in the definition lol) with "SetVirtualWorld".
You don't need to. You can just name it SetPlayerVirtualWorld and it'll overwrite SetPlayerVirtualWorld.
Yeah seif's right. If i was going to define it, i'd much rather do it like this:


pawn Код:
stock SetPlayerVirtualWorldEx(playerid, worldid)
{
    CallRemoteFunction("OnPlayerVirtualWorldChange", "iii", playerid, GetPlayerVirtualWorld(playerid), worldid);
    return SetPlayerVirtualWorld(playerid, worldid);
}

#define SetPlayerVirtualWorld SetPlayerVirtualWorldEx

that way i don't have to change anything. There are two problems with this way though. I dont want to put that in EVERY script that uses SetPlayerVirtualWorld (quite a lot of my scripts do, as its a vital part of my server) and also, i think that would be less efficient (Making a remote call every time i set a players virtual world is probably just as bad as using OnPlayerUpdate).

In the end, both ways have their down sides, but i just prefer OnPlayerUpdate. I normally stay away from OnPlayerUpdate, but i figure this is what it was made for / cant be TO bad (other wise, why add it in the first place) :P.

Reply


Messages In This Thread
WiKi Examples - Moderation?! - by theRealG - 11.05.2010, 23:13
Re: WiKi Examples - Moderation?! - by Simon - 12.05.2010, 09:24
Re: WiKi Examples - Moderation?! - by XRVX - 12.05.2010, 09:28
Re: WiKi Examples - Moderation?! - by theRealG - 12.05.2010, 11:58
Re: WiKi Examples - Moderation?! - by dice7 - 12.05.2010, 13:28
Re: WiKi Examples - Moderation?! - by Kyosaur - 12.05.2010, 18:11
Re: WiKi Examples - Moderation?! - by [XAC]Klinsen - 13.05.2010, 19:36
Re: WiKi Examples - Moderation?! - by Sergei - 13.05.2010, 19:53
Re: WiKi Examples - Moderation?! - by Kyosaur - 14.05.2010, 22:18
Re: WiKi Examples - Moderation?! - by jackofbladesmah - 19.05.2010, 14:22

Forum Jump:


Users browsing this thread: 1 Guest(s)