Creating individual world for events
#1

Hello everyone, I was wondering could somebody help me with how to code a new world kind of thing. Let me explain. I have scripted a kind of mini game within my server, and when you do /startcc it starts it by teleporting you to the game, but is there anyway I can have them teleported to a different world so if the next person starts the game they wont be in the same gamemode? Its basically so more than one person at a time can play the minigame. Thanks.

If the code is needed just ask please.
Reply
#2

You mean virtual world?
Reply
#3

new world;

When they game is full.

SetPlayerVirtualWorld(playerid, world+1);
world+1;

If you have vehicles to transfer it'll be more difficult. You'll have to pass all the vehicles in that game to the virtual world. If need it, give us the Vehicle Info array.
Reply
#4

Since two players can never have the same VW you can simply do this

Код:
SetPlayerPos(playerid, 0, 0, 5); //for example
SetPlayerVirtualWorld(playerid, playerid+1);// I added +1 so player ID 0 won't stay in the real virtual world
if (GetPlayerState(giveplayerid) == 2)
{
	new tmpcar = GetPlayerVehicleID(playerid);
	SetVehiclePos(tmpcar, 0, 0, 10);
	LinkVehicleToInterior(tempcar, GetPlayerInterior(playerid));
	SetVehicleVirtualWorld(tempcar,playerid+1);
}
Reply
#5

Is there anyway I can have two players in the virtual world? Not just me like?
Reply
#6

And do they have a command like /playwith [ID] or they will be set randomly?
Reply
#7

Quote:
Originally Posted by mirou123
Посмотреть сообщение
And do they have a command like /playwith [ID] or they will be set randomly?
I don't understand the question?
Reply
#8

I mean you want two players to play with each other right?How is the second player going to play with the first player?Does he have a command like for example /playwith [The id of the player you want to play with] or they just type /play and they will be teleported to a random player in the mini-game?
Reply
#9

I dont know, i wanted their to be a command like "Man has requested to play a CopChase with you. Type /acceptcopchase to join. If you could show me how to create that, that would be great.
Reply
#10

Код:
//On top of your script:
new CopChaseInviter[MAX_PLAYERS] = INVALID_PLAYER_ID;

// Anywhere if you don't have something like GetPlayerNameEx
stock GetPlayerNameEx(playerid)
{
    new playerName[MAX_PLAYER_NAME];

    if(IsPlayerConnected(playerid))
    {
		GetPlayerName(playerid, playerName, sizeof(playerName));
	}
	return playerName;
}

//next to your commands
CMD:copchase(playerid, params[])
{
       new string[128], playerb;
	if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, -1, "USAGE: /copchase [playerid]");
        CopChaseInviter[playerb] = playerid;
        format(string,sizeof(string),"%s has requested to join your CopChase game", GetPlayerNameEx(playerid));
        SendClientMessage(playerid, -1, string);
        return 1;
}

CMD:acceptcopchase(playerid, params[])
{
    new playerb = CopChaseInviter[playerid];
    SetPlayerPos(playerb, 0, 0, 5); //for example
    SetPlayerVirtualWorld(playerb, playerid+1);// I added +1 so player ID 0 won't stay in the real virtual world
    if (GetPlayerState(playerb) == 2)
    {
	new tmpcar = GetPlayerVehicleID(playerb);
	SetVehiclePos(tmpcar, 0, 0, 10);
	LinkVehicleToInterior(tempcar, GetPlayerInterior(playerb));
	SetVehicleVirtualWorld(tempcar,playerid+1);
     }
     return 1;
}
I did not test this and it still need improvement like checking if the first player is even in a CopChase game or not etc....But this will give you an idea on how to do it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)