Change the world of the objects
#1

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
Reply
#2

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.
Reply
#3

it didnt
Reply
#4

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

use a streamer
Reply
#6

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

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

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
Reply
#9

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?)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)