Is this possible? about Virtual World
#1

I want to make if there are 2 players dueling in virtual world 10, and if 2 more wants to duel they should go in virtual world 11 and so on, so they don't disturb players dueling in virtual world 10, i don't know how to check there are players in virtual world 10 or not :\ can anyone help plz

pawn Код:
new IsInDuel[MAX_PLAYERS];
new Dueler[MAX_PLAYERS];
And here's the /accept command

pawn Код:
CMD:accept(playerid, params[])
{
    new string[128];
    if(IsInDuel[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Are Already in Duel!");
    if(Dueler[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "No one has sent you a Duel Request.");

    format(string, sizeof(string), "** %s (%d) Has Accepted Your Duel Request", GetName(playerid), playerid);
    SendClientMessage(Dueler[playerid], COLOR_ORANGE, string);
    format(string, sizeof(string), "You've Accepted %s (%d) Duel Request", GetName(Dueler[playerid]), Dueler[playerid]);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);

    format(string, sizeof(string), "The Duel Between %s and %s Has Started!", GetName(Dueler[playerid]), GetName(playerid));
    SendClientMessageToAll(COLOR_ORANGE, string);
   
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerPos(Dueler[playerid], x, y, z);
    SetPlayerInterior(playerid, 16);
    SetPlayerInterior(Dueler[playerid], 16);
    SetPlayerVirtualWorld(playerid, 10);
    SetPlayerVirtualWorld(Dueler[playerid], 10);
    SetPlayerPos(playerid, -1395.067, 1261.3706, 1042.8672);
    SetPlayerPos(Dueler[playerid], -1395.067, 1261.3706, 1042.8672);
    SetPlayerHealth(playerid, 100.0);
    SetPlayerHealth(Dueler[playerid], 100.0);
    SetPlayerArmour(playerid, 100.0);
    SetPlayerArmour(Dueler[playerid], 100.0);
    IsInDuel[playerid] = 1;
    IsInDuel[Dueler[playerid]] = 1;
    return 1;
}
Reply
#2

You have to make a variable (global) for example, g_Worls and when 2 players start dueling put 1 more point to the variable. I know i havent explain very well here is an example:
pawn Код:
new g_World;
g_World = 10; //the starting virtual world
CMD:accept(playerid, params[])
{
    new string[128];
    if(IsInDuel[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Are Already in Duel!");
    if(Dueler[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "No one has sent you a Duel Request.");

    format(string, sizeof(string), "** %s (%d) Has Accepted Your Duel Challenge.", GetName(playerid), playerid);
    SendClientMessage(Dueler[playerid], COLOR_ORANGE, string);
    format(string, sizeof(string), "You've Accepted %s (%d) Duel Challenge!.", GetName(Dueler[playerid]), Dueler[playerid]);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);

    format(string, sizeof(string), "The Duel Between %s and %s Has Started!", GetName(Dueler[playerid]), GetName(playerid));
    SendClientMessageToAll(COLOR_ORANGE, string);
   
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerPos(Dueler[playerid], x, y, z);
    SetPlayerInterior(playerid, 16);
    SetPlayerInterior(Dueler[playerid], 16);
    SetPlayerVirtualWorld(playerid, g_World);
    SetPlayerVirtualWorld(Dueler[playerid], g_World);
    g_World ++;
    SetPlayerPos(playerid, -1395.067, 1261.3706, 1042.8672);
    SetPlayerPos(Dueler[playerid], -1395.067, 1261.3706, 1042.8672);
    SetPlayerHealth(playerid, 100.0);
    SetPlayerHealth(Dueler[playerid], 100.0);
    SetPlayerArmour(playerid, 100.0);
    SetPlayerArmour(Dueler[playerid], 100.0);
    IsInDuel[playerid] = 1;
    IsInDuel[Dueler[playerid]] = 1;
    return 1;
}
Reply
#3

As JustBored suggested, create a global variable that will (obviously) start out on one, and when there is a duel in progress set them to +1 of the global variable, meaning that no one would ever land in that duel. It's fortunate for the way SAMP works because you won't have to worry about limited virtual worlds (unless you have 100,000,000,000 duels a day.)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)