Change the world of the objects
#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


Messages In This Thread
Change the world of the objects - by aybo - 24.12.2011, 18:03
Re: Change the world of the objects - by prisonliferp - 24.12.2011, 18:13
Re: Change the world of the objects - by aybo - 24.12.2011, 19:16
Re: Change the world of the objects - by prisonliferp - 24.12.2011, 19:30
Re: Change the world of the objects - by dowster - 24.12.2011, 19:34
Re: Change the world of the objects - by prisonliferp - 24.12.2011, 19:39
Re: Change the world of the objects - by Scenario - 24.12.2011, 19:42
AW: Change the world of the objects - by Nero_3D - 24.12.2011, 19:51
Re: AW: Change the world of the objects - by prisonliferp - 24.12.2011, 19:55

Forum Jump:


Users browsing this thread: 2 Guest(s)