[Tutorial] VirtualWorld
#1

Oque й um Virtual World?

Um virtual world й uma funзгo que seta o player б um mundo diferente que ele nasceu.
Ele й muito usado para usar o mesmo interior em 2 hqs. A funзгo funciona assim

pawn Код:
if(PlayerToPoint(2, playerid,957.9416,-1556.2628,13.5802))
{//ENTRADA HQ 1
GameTextForPlayer(playerid, "~w~HQ 1", 5000, 1);
SetPlayerInterior(playerid, 6);
SetPlayerPos(playerid,343.7183,304.9376,999.1484);
PlayerInfo[playerid][pInt] = 6;
SetPlayerVirtualWorld(playerid, 1);
}
else if(PlayerToPoint(2, playerid,-1681.4905,1350.2188,7.1722))
{//ENTRADA HQ 2
GameTextForPlayer(playerid, "~w~HQ 2", 5000, 1);
SetPlayerInterior(playerid, 6);
SetPlayerPos(playerid,343.7183,304.9376,999.1484);
PlayerInfo[playerid][pInt] = 6;
SetPlayerVirtualWorld(playerid, 2);
}
Como vocк pode ver usamos o mesmo interior para 2 locais diferentes (Casa 1 e Casa 2)

Mais Matheus eu ao sair do interior eu saio no mesmo lugar da outra HQ!
Entгo й sу vocк usar a funзгo abaixo.

pawn Код:
if(PlayerToPoint(1.0, playerid,343.7183,304.9376,999.1484) && GetPlayerVirtualWorld(playerid) == 1)//Aki getara o player caso ele entra no mundo 1 ele getara para GetPlayerVirtualWorld(playerid) == 1, para verificar se o player estava no mundo 1 e setar ele na pos de entrada correta.
{//SAIDA HQ 1
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid,957.9416,-1556.2628,13.5802);
PlayerInfo[playerid][pInt] = 0;
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pLocal] = 255;
}
else if(PlayerToPoint(1.0, playerid,343.7183,304.9376,999.1484) && GetPlayerVirtualWorld(playerid) == 2)//Aki getara o player caso ele entra no mundo 2 ele getara para GetPlayerVirtualWorld(playerid) == 2, para verificar se o player estava no mundo 2 e setar ele na pos de entrada correta.
{//SAIDA HQ 2
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid,-1681.4905,1350.2188,7.1722);
PlayerInfo[playerid][pInt] = 0;
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pLocal] = 255;
}
Criticas? Sujestoes? Sу falar ai

Crйditos:

Matheus Vieira pelo tutorial.
Tutorial feito em resposta ao tуpico: https://sampforum.blast.hk/showthread.php?tid=324086&page=2
Reply
#2

Poderia explicar as funзхes e etc.
Mais o que vale e a intenзгo.

Й essas definiзхes/variaveis sei lб o nome, que eu saiba irб dar error no GM.
Reply
#3

pawn Код:
if(PlayerToPoint(1.0, playerid,343.7183,304.9376,999.1484) && GetPlayerVirtualWorld(playerid) == 2)//Aki getara o player caso ele entra no mundo 2 ele getara para GetPlayerVirtualWorld(playerid) == 2, para verificar se o player estava no mundo 2 e setar ele na pos de entrada correta.
{//SAIDA HQ 2
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid,-1681.4905,1350.2188,7.1722);
PlayerInfo[playerid][pInt] = 0;
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pLocal] = 255;
}
Pra Que Seta o Interior 2 Vezes?
Reply
#4

Que vergonha disso --'
Vocк tem bola de cristal para saber se o cara usa o BMG (PlayerInfo --') Isso com certeza vai dar erro ¬ Alйm disso vocк nгo explicou nada e a estб com uma pйssima Indentaзгo -q
Reply
#5

Alйm disso;

[pInt] e [pLocal] provavelmente irб dar error, GF.
Reply
#6

realmente pegou codigo pronto e isso nao estб explicado em nada apenas codigo pronto..
Reply
#7

Quote:
Originally Posted by mau.tito
Посмотреть сообщение
pawn Код:
if(PlayerToPoint(1.0, playerid,343.7183,304.9376,999.1484) && GetPlayerVirtualWorld(playerid) == 2)//Aki getara o player caso ele entra no mundo 2 ele getara para GetPlayerVirtualWorld(playerid) == 2, para verificar se o player estava no mundo 2 e setar ele na pos de entrada correta.
{//SAIDA HQ 2
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid,-1681.4905,1350.2188,7.1722);
PlayerInfo[playerid][pInt] = 0;
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pLocal] = 255;
}
Pra Que Seta o Interior 2 Vezes?
ele nao seto 2 veses veja em cima ta definido que ele ta no interior 2 e ira pro interior 0

Reply
#8

Deu uma cabada de erros >> PlayerInfo << meu gm num usa isso n fi
Reply
#9

para quem nгo entendeu vou dar um breve tutorial de virtualwordl

funзгo: SetPlayerVirtualWorld(playerid,vitualworldid);
OBS: o limite de virtuaisworlds й quase inacabбvel suhsuhs
mundo = virtual world
quando o jogador se conecta por padrгo ele й colocado no mundo 0
quando colocado em outro mundo, ele nao verб mais os carros,players e outros do mundo 0,
esta funзгo geralente й utilizada para separar o jogador do normal, em eventos, em off etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)