SA-MP Forums Archive
Creating individual world for events - 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: Creating individual world for events (/showthread.php?tid=501113)



Creating individual world for events - Ciarannn - 16.03.2014

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.


Re: Creating individual world for events - Abagail - 16.03.2014

You mean virtual world?


Respuesta: Creating individual world for events - Stront - 16.03.2014

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.


Re: Creating individual world for events - mirou123 - 16.03.2014

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);
}



Re: Creating individual world for events - Ciarannn - 16.03.2014

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


Re: Creating individual world for events - mirou123 - 16.03.2014

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


Re: Creating individual world for events - Ciarannn - 16.03.2014

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?


Re: Creating individual world for events - mirou123 - 16.03.2014

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?


Re: Creating individual world for events - Ciarannn - 16.03.2014

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.


Re: Creating individual world for events - mirou123 - 16.03.2014

Код:
//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