SA-MP Forums Archive
Add OnPlayerWorldChange - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP DL Edition (https://sampforum.blast.hk/forumdisplay.php?fid=92)
+--- Forum: SA-MP 0.3.DL (https://sampforum.blast.hk/forumdisplay.php?fid=90)
+--- Thread: Add OnPlayerWorldChange (/showthread.php?tid=648530)



Add OnPlayerWorldChange - willttoonn - 24.01.2018

Suggestion to add native OnPlayerWorldChange in 0.3.7-DL and 0.3.7.

OnPlayerWorldChange

Description: Called when a player changes virtual world.

Parameters: (playerid, newvwid, oldvwid)


Re: Add OnPlayerWorldChange - Abagail - 24.01.2018

Virtual worlds (IIRC) can not be changed client side and there are no triggers that change them (e.g: the yellow markers if enabled, they only change interior ID).

That said, you can hook SetPlayerVirtualWorld and call this directly with essentially no negative performance impact already.


Re: Add OnPlayerWorldChange - willttoonn - 24.01.2018

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Virtual worlds (IIRC) can not be changed client side and there are no triggers that change them (e.g: the yellow markers if enabled, they only change interior ID).

That said, you can hook SetPlayerVirtualWorld and call this directly with essentially no negative performance impact already.
OnPlayerWorldChange with similar fuction to native OnPlayerInteriorChange in server-side, this is not possible?


Re: Add OnPlayerWorldChange - MatheusDark - 24.01.2018

I support this idea. It would help in the issue of some bugs with the virtual world.


Re: Add OnPlayerWorldChange - Sew_Sumi - 24.01.2018

You can make this, and the amount of usage it would have is pretty slim...

It's not like an interior that changes often in the game itself, where the VW is forcibly changed by the script anyway, so as Abagail said, you could easily hook into SetPlayerVirtualWorld, and simply track it in this.

Gammix already even made it... https://sampforum.blast.hk/showthread.php?tid=573961

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Код:
public OnPlayerVirtualWorldChange(playerid, newworld, oldworld);



Re: Add OnPlayerWorldChange - raydx - 24.01.2018

Here you are:

Код:
stock _SetPlayerVirtualWorld(playerid, world)
{
	OnPlayerWorldChange(playerid, GetPlayerVirtualWorld(playerid), world);
        SetPlayerVirtualWorld(playerid, world);
}
#define SetPlayerVirtualWorld(%0,%1) _SetPlayerVirtualWorld(%0,%1)



Re: Add OnPlayerWorldChange - iKarim - 24.01.2018

Quote:
Originally Posted by raydx
Посмотреть сообщение
Here you are:

Код:
stock _SetPlayerVirtualWorld(playerid, world)
{
	OnPlayerWorldChange(playerid, GetPlayerVirtualWorld(playerid), world);
}
#define SetPlayerVirtualWorld(%0,%1) _SetPlayerVirtualWorld(%0,%1)
Nope. This won't change the virtual world, making the Set function fairly useless.
PHP код:
stock S_SetPlayerVirtualWorldplayeridworld )
{
    
OnPlayerWorldChangeplayeridGetPlayerVirtualWorld(playerid), world );
    return 
SetPlayerVirtualWorldplayeridworld );
}
#if defined _ALS_SetPlayerVirtualWorldOnVirtualWorldChange
    #undef SetPlayerVirtualWorld
#else
    #define _ALS_SetPlayerVirtualWorld
#endif
#define SetPlayerVirtualWorld S_SetPlayerVirtualWorld 



Re: Add OnPlayerWorldChange - Sew_Sumi - 24.01.2018

This is what's good ^^


Re: Add OnPlayerWorldChange - ZiGGi - 24.01.2018

I think what SetPlayerVirtualWorld should be called before OnPlayerWorldChange.


Re: Add OnPlayerWorldChange - raydx - 24.01.2018

Quote:
Originally Posted by iKarim
Посмотреть сообщение
Nope. This won't change the virtual world, making the Set function fairly useless.
PHP код:
stock S_SetPlayerVirtualWorldplayeridworld )
{
    
OnPlayerWorldChangeplayeridGetPlayerVirtualWorld(playerid), world );
    return 
SetPlayerVirtualWorldplayeridworld );
}
#if defined _ALS_SetPlayerVirtualWorldOnVirtualWorldChange
    #undef SetPlayerVirtualWorld
#else
    #define _ALS_SetPlayerVirtualWorld
#endif
#define SetPlayerVirtualWorld S_SetPlayerVirtualWorld 
Just forgot to add SetPlayerVirtualWorld, its fixed now. Anyway, that ALS things are useless in this case.


Re: Add OnPlayerWorldChange - Sew_Sumi - 24.01.2018

Those 'ALS things' are more advanced than what you are capable of, but do not make them useless.


Re: Add OnPlayerWorldChange - Meller - 24.01.2018

why would you even want this when it can only be modified through script and not by a client at all except if the player is using modified game files (asi, samods, cleo etc)


Re: Add OnPlayerWorldChange - Mugala - 27.01.2018

client can't change virtual world, so you can create its callback manually, without any incs/plugins.