Setting variables
#1

PHP код:
if(dialogid == DIALOG_ARENAS1)
    {
     if(
response)
        { 
// here the setplayerpos sets player in air.... i took these from samp site ill show ya
            
if(playerData[playerid][playerWantedLevel] < 3)
            {    
            
                    if(
listitem == 0)
                    {
                        
SetPlayerPos(playerid1412.639892,-1.787510,1000.924377);
                        
SetPlayerInterior(playerid1); //kickstart arena intid
                        
SetPlayerVirtualWorld(playerid20);
                        
playerData[playerid][IsInArena1] = 1;
                        
playerData[playerid][IsInAArena] = 1;
                        
playerData[playerid][isInDuel] = false;
                        
playerData[playerid][isinFREEFORALL] = false;
                        
playerData[playerid][isInCVR] = false;
                        
playerData[playerid][onRace1] = false;
                        
printf("IsInDuel: %i, onRace: %i, isInCVR: %i, isinFREEFORALL: %i, ISINARENA: %b",playerData[playerid][isInDuel], playerData[playerid][onRace1], playerData[playerid][isInCVR], playerData[playerid][isinFREEFORALL], playerData[playerid][IsInAArena]);
                        
SetPlayerHealth(playerid100);
                        
SetPlayerArmour(playerid99);
                        
ResetPlayerWeapons(playerid);
                        
GivePlayerWeaponEx(playeridWEAPON_DEAGLE6000);
                        
GivePlayerWeaponEx(playeridWEAPON_SNIPER6000);
                        
                    }
                    if(
listitem == 1)
                    {
                        
SetPlayerPos(playerid1412.639892,-1.787510,1000.924377);
                        
SetPlayerInterior(playerid1); //kickstart arena intid
                        
SetPlayerVirtualWorld(playerid21);
                        
playerData[playerid][IsInArena2] = 1;
                        
playerData[playerid][IsInAArena] = 1;
                        
playerData[playerid][isInDuel] = false;
                        
playerData[playerid][isinFREEFORALL] = false;
                        
playerData[playerid][isInCVR] = false;
                        
playerData[playerid][onRace1] = false;
                        
printf("IsInDuel: %i, onRace: %i, isInCVR: %i, isinFREEFORALL: %i, ISINARENA: %b",playerData[playerid][isInDuel], playerData[playerid][onRace1], playerData[playerid][isInCVR], playerData[playerid][isinFREEFORALL], playerData[playerid][IsInAArena]);
                        
SetPlayerHealth(playerid100);
                        
SetPlayerArmour(playerid99);
                        
ResetPlayerWeapons(playerid);
                        
GivePlayerWeaponEx(playeridWEAPON_DEAGLE6000);
                        
GivePlayerWeaponEx(playeridWEAPON_SAWEDOFF6000);
                    }
                    if(
listitem == 2)
                    {
                        
SetPlayerPos(playerid1412.639892,-1.787510,1000.924377);
                        
SetPlayerInterior(playerid1); //kickstart arena intid
                        
SetPlayerVirtualWorld(playerid22);
                        
playerData[playerid][IsInArena3] = 1;
                        
playerData[playerid][IsInAArena] = 1;
                        
playerData[playerid][isInDuel] = false;
                        
playerData[playerid][isinFREEFORALL] = false;
                        
playerData[playerid][isInCVR] = false;
                        
playerData[playerid][onRace1] = false;
                        
printf("IsInDuel: %i, onRace: %i, isInCVR: %i, isinFREEFORALL: %i, ISINARENA: %i",playerData[playerid][isInDuel], playerData[playerid][onRace1], playerData[playerid][isInCVR], playerData[playerid][isinFREEFORALL], playerData[playerid][IsInAArena]);
                        
ResetPlayerWeapons(playerid);
                        
SetPlayerHealth(playerid100);
                        
SetPlayerArmour(playerid99);
                        
GivePlayerWeaponEx(playeridWEAPON_SHOTGSPA6000);
                        
GivePlayerWeaponEx(playeridWEAPON_MP56000);
                    }
                    if(
listitem == 3)
                    {
                        
SetPlayerPos(playerid1412.639892,-1.787510,1000.924377);
                        
SetPlayerInterior(playerid1); //kickstart arena intid
                        
SetPlayerVirtualWorld(playerid23);
                        
playerData[playerid][IsInArena4] = 1;
                        
playerData[playerid][IsInAArena] = 1;
                        
playerData[playerid][isInDuel] = false;
                        
playerData[playerid][isinFREEFORALL] = false;
                        
playerData[playerid][isInCVR] = false;
                        
playerData[playerid][onRace1] = false;
                        
printf("IsInDuel: %i, onRace: %i, isInCVR: %i, isinFREEFORALL: %i, ISINARENA: %i",playerData[playerid][isInDuel], playerData[playerid][onRace1], playerData[playerid][isInCVR], playerData[playerid][isinFREEFORALL], playerData[playerid][IsInAArena]);
                        
SetPlayerHealth(playerid100);
                        
SetPlayerArmour(playerid99);
                        
ResetPlayerWeapons(playerid);
                        
GivePlayerWeaponEx(playeridWEAPON_SNIPER6000);
                        
GivePlayerWeaponEx(playeridWEAPON_SAWEDOFF6000);
                    }
                    if(
listitem == 4)
                    {
                        
SetPlayerPos(playerid1412.639892,-1.787510,1000.924377);
                        
SetPlayerInterior(playerid1); //kickstart arena intid
                        
SetPlayerVirtualWorld(playerid24);
                        
playerData[playerid][IsInArena5] = 1;
                        
playerData[playerid][IsInAArena] = 1;
                        
playerData[playerid][isInDuel] = false;
                        
playerData[playerid][isinFREEFORALL] = false;
                        
playerData[playerid][isInCVR] = false;
                        
playerData[playerid][onRace1] = false;
                        
printf("IsInDuel: %i, onRace: %i, isInCVR: %i, isinFREEFORALL: %i, ISINARENA: %i",playerData[playerid][isInDuel], playerData[playerid][onRace1], playerData[playerid][isInCVR], playerData[playerid][isinFREEFORALL], playerData[playerid][IsInAArena]);
                        
SetPlayerHealth(playerid100);
                        
SetPlayerArmour(playerid99);
                        
ResetPlayerWeapons(playerid);
                        
GivePlayerWeaponEx(playeridWEAPON_SNIPER6000);
                        
GivePlayerWeaponEx(playeridWEAPON_SHOTGSPA6000);
                    }
            }
            else
                {
                    
SendClientMessage(playeridCOLOR_RED"You cannot enter duel arena with wanted level!");
                }    
        }    
    return 
1;    

Basically i am trying to set the IsInAArena var to 1, but it never sets to one... remains to 0

Basically i have to check onplayerspawn if its 1, spawn player in arena otherwise normal spawn, here's onplayer spawn code:

PHP код:
if(playerData[playerid][IsInAArena] == 1// respawn in arena if died in arena
    
{
        if(
playerData[playerid][IsInArena1] == 1)
        {
            
SetPlayerPos(playerid, -1410.72,1591.16,1052.53);
            
SetPlayerInterior(playerid14);
            
SetPlayerVirtualWorld(playerid20);
        }
        else if(
playerData[playerid][IsInArena2] == 1)
        {
            
SetPlayerPos(playerid, -1410.72,1591.16,1052.53);
            
SetPlayerInterior(playerid14);
            
SetPlayerVirtualWorld(playerid21);
        }
        else if(
playerData[playerid][IsInArena3] == 1)
        {
            
SetPlayerPos(playerid, -1410.72,1591.16,1052.53);
            
SetPlayerInterior(playerid14);
            
SetPlayerVirtualWorld(playerid22);
        }
        else if(
playerData[playerid][IsInArena4] == 1)
        {
            
SetPlayerPos(playerid, -1410.72,1591.16,1052.53);
            
SetPlayerInterior(playerid14);
            
SetPlayerVirtualWorld(playerid23);
        }
        else if(
playerData[playerid][IsInArena5] == 1)
        {
            
SetPlayerPos(playerid, -1410.72,1591.16,1052.53);
            
SetPlayerInterior(playerid14);
            
SetPlayerVirtualWorld(playerid24);
        }
        
SendClientMessage(playerid, -1"You spawned in a duel arena! use /leavearena to leave the duel arena!");
        return 
1;
    } 
Btw, isinaarena is int.
Reply
#2

The arenas appear to be mutually exclusive. That is: a player can only enter one arena at a time. So I'm puzzled as to why you choose to have five variables that can be either 0 or 1, as opposed to one variable that can be 1, 2, 3, 4 or 5. This is surely a lot cleaner and a lot more expandable.
Reply
#3

You mean an array? That won't be a problem... But real problem is that those cars never change to 1 even when a player enters arena.
Reply
#4

Why do you do it like that?
Can't you just have 1 variable, and set it to an area id?

For example:

Код:
area1[playerid] = 1;
..
area2[playerid] = 1;

------

area[playerid] = 1;
area[playerid] = 2;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)