SA-MP Forums Archive
Change the world of the objects - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Change the world of the objects (/showthread.php?tid=306007)



Change the world of the objects - aybo - 24.12.2011

Hi there. In our gamemode we have 2 worlds. One is for lobby and one is for bases. I want to add objects to my lobby world and i dont want to see them in the world for the bases.
Hope you got it. Thanks


Re: Change the world of the objects - prisonliferp - 24.12.2011

I dont think you can do that to be honest, you can usually set a players virtual world or interior to something special, but if you add a object somewhere it should be in every VW & Interior.


+Rep if my post helped you.


Re: Change the world of the objects - aybo - 24.12.2011

it didnt


Re: Change the world of the objects - prisonliferp - 24.12.2011

You cannot change a object's interior or virtual world.


Re: Change the world of the objects - dowster - 24.12.2011

use a streamer


Re: Change the world of the objects - prisonliferp - 24.12.2011

Dowster, it still wont change the objects's virtual world and interior, objects are spawned in EACH single interior & virtual world


Re: Change the world of the objects - Scenario - 24.12.2011

I don't think you can do this with the native file functions... However, with a streamer, it's possible...!


AW: Change the world of the objects - Nero_3D - 24.12.2011

You could script virtual words for objects and its not very difficult...

You just need to create a new SetPlayerVirtualWorld function and use CreatePlayerObject

Here a huge example code
pawn Код:
// costum SetPlayerVirutalWorld function
stock ovwSetPlayerVirtualWorld(playerid, const newWorldid) {
    new
        oldWorldid = GetPlayerVirtualWorld(playerid);
    if((oldWorldid != newWorldid) && SetPlayerVirtualWorld(playerid, newWorldid)) {
        return OnPlayerVirtualWorldChange(playerid, newWorldid, oldWorldid);
    }
    return false;
}
forward OnPlayerVirtualWorldChange(playerid, newWorldid, oldWorldid);
#define SetPlayerVirtualWorld ovwSetPlayerVirtualWorld
pawn Код:
new // similar system as YSI_objects
    ObjectInfo[TOTAL_OBJECTS][OI_ENUM],
    PlayerObject[MAX_PLAYERS][MAX_OBJECTS];
pawn Код:
public OnPlayerVirtualWorldChange(playerid, newWorldid, oldWorldid) {
    for(new i; i != sizeof ObjectInfo; ++i) {
        if(ObjectInfo[i][Active][playerid]) { // if the object is spawned for the player
            if(ObjectInfo[i][VirtualWorld] == -1) { // global objects
                continue;
            } // if its not global it must be in another virtual world => so we can destroy it
            for(new o; o != sizeof PlayerObject; ++o) {
                if(PlayerObject[playerid][o] == i) {
                    ObjectInfo[i][Active][playerid] = false; // set the active status to false
                    DestroyPlayerObject(playerid, o); // destroy player object
                    PlayerObject[playerid][o] = -1;
                    break;
                }
            }
        } else { // if the object is not spawned
            if(ObjectInfo[i][VirtualWorld] == newWorldid) {
                new // create player object
                    objectid = CreatePlayerObject(playerid, ...);
                if(objectid != INVALID_OBJECT_ID) {
                    ObjectInfo[i][Active][playerid] = true; // Active should be a bit array (y_bit)
                    PlayerObject[playerid][objectid] = i; // connect objectid and data
                }
            }
        }
    }
    return true;
}
As you just saw, the main problem is that you would need a ObjectData array
Such an array uses a lot of space and is only effectively used within a streamer

Just use a existing streamer with such a function


Re: AW: Change the world of the objects - prisonliferp - 24.12.2011

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
You could script virtual words for objects and its not very difficult...

You just need to create a new SetPlayerVirtualWorld function and use CreatePlayerObject
Oh ye', that's right lol.. (Might be alot of work depending on how many objects you got?)