[Ajuda] OnPlayerKeyStateChange
#1

Olб, depois de um tempo afastado do pwn, estou retornando agora. Preciso de uma ajuda, nгo consigo entender o motivo do codigo a baixo nгo funcionar.

Eu consigo entrar na casa, porem nгo consigo entrar na empresa, se eu apagar a funзгo de entrar na casa, ai sim consigo entrar na empresa.

Em minha "Logica" quando aperto o botгo Enter/F estб apenas lendo a primeira funзгo. alguem pode me dizer onde estou errando nesse codigo. Agradeзo ...

PHP код:

public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
string[128];
    
    
// Entrar Casa
    
if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if(!
pInfo[playerid][dentrocasa])
        {
            new 
timestamp GetTickCount();
            if(
timestamp inhousepickup[playerid] > 1000)
            {
                return 
1;
            }
            
            
format(STRXsizeof(STRX), "Casaid %d"playericonhouse[playerid]);
            
GetPlayerName(playeridpInfo[playerid][Nome], 24);
            if(
hInfo[playericonhouse[playerid]][SemInt] == 1) return SendClientMessage(playerid, -1"Casa sem portas");
            
            if(
strcmp(hInfo[playericonhouse[playerid]][Dono], pInfo[playerid][Nome], true) == 0)
            {
                
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
                
SetPlayerVirtualWorld(playeridhInfo[playericonhouse[playerid]][Virtualworld]);
                
SetPlayerInterior(playeridhInfo[playericonhouse[playerid]][Interior]);
                
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]);
                
playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior];
                
pInfo[playerid][dentrocasa] = true;
                
format(stringsizeof(string), "Bem vindo a sua casa"hInfo[playericonhouse[playerid]][ID]);
                
SendClientMessage(playerid, -1string);
                return 
1;
            }
            
            if(
hInfo[playericonhouse[playerid]][Locked] == true) return SendClientMessage(playerid, -1"Essa casa estб trancada");
            
            
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
            
SetPlayerVirtualWorld(playeridhInfo[playericonhouse[playerid]][Virtualworld]);
            
SetPlayerInterior(playeridhInfo[playericonhouse[playerid]][Interior]);
            
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]);
            
playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior];
            
pInfo[playerid][dentrocasa] = true;
            
format(stringsizeof(string), "Bem vindo б CASA ID %d"hInfo[playericonhouse[playerid]][ID]);
            
SendClientMessage(playerid, -1string);
        }
        else
        {
            if(
GetPlayerInterior(playerid) == playerinterior[playerid])
            {
                if(
IsPlayerInRangeOfPoint(playerid2.0hInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]))
                {
                    
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony],hInfo[playericonhouse[playerid]][iconz]);
                    
SetPlayerInterior(playeridplayerworld[playerid]);
                    
SetPlayerVirtualWorld(playerid0);
                    
pInfo[playerid][dentrocasa] = false;
                    
format(stringsizeof(STRX), "Vocк saiu da casa %d."hInfo[playericonhouse[playerid]][ID]);
                    
SendClientMessage(playerid, -1string);
                }
                else
                {
                    
SendClientMessage(playerid, -1"Vocк estб longe da porta!");
                    return 
1;
                }
            }
        }
    }
    
    
// Entrar Empresa
    
if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if(!
pInfo[playerid][dentroEmpresa])
        {
            new 
timestamp GetTickCount();
            if(
timestamp inEmpresapickup[playerid] > 1000)
            {    
                return 
1;
            }
            
            
format(STRXsizeof(STRX), "Empresa ID : %d"playericonEmpresa[playerid]);
            
GetPlayerName(playeridpInfo[playerid][Nome], 24);
            if(
eInfo[playericonEmpresa[playerid]][eSemInt] == 1) return SendClientMessage(playerid, -1"nгo tem portas!");
            
            if(
strcmp(eInfo[playericonEmpresa[playerid]][eDonoEmpresa], pInfo[playerid][Nome], true) == 0)
            {
                
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
                
SetPlayerVirtualWorld(playerideInfo[playericonEmpresa[playerid]][eVirtualworld]);
                
SetPlayerInterior(playerideInfo[playericonEmpresa[playerid]][eInterior]);
                
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]);
                
playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior];
                
pInfo[playerid][dentroEmpresa] = true;
                
format(stringsizeof(string), "Sua Empresa de ID : %d "eInfo[playericonEmpresa[playerid]][eID]);
                
SendClientMessage(playerid, -1string);
                return 
1;
            }
            
            if(
eInfo[playericonEmpresa[playerid]][eLocked] == true) return SendClientMessage(playerid, -1"Empresa estб fechada");
            
            
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
            
SetPlayerVirtualWorld(playerideInfo[playericonEmpresa[playerid]][eVirtualworld]);
            
SetPlayerInterior(playerideInfo[playericonEmpresa[playerid]][eInterior]);
            
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]);
            
playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior];
            
pInfo[playerid][dentroEmpresa] = true;
            
format(stringsizeof(string), "Empresa ID : %d."eInfo[playericonEmpresa[playerid]][eID]);
            
SendClientMessage(playerid, -1string);
        }
        else
        {
            if(
GetPlayerInterior(playerid) == playerinterior[playerid])
            {
                if(
IsPlayerInRangeOfPoint(playerid2.0eInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]))
                {
                    
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eiconx], eInfo[playericonEmpresa[playerid]][eicony],eInfo[playericonEmpresa[playerid]][eiconz]);
                    
SetPlayerInterior(playeridplayerworld[playerid]);
                    
SetPlayerVirtualWorld(playerid0);
                    
pInfo[playerid][dentroEmpresa] = false;
                    
format(stringsizeof(STRX), "saiu da Empresa ID : %d."eInfo[playericonEmpresa[playerid]][eID]);
                    
SendClientMessage(playerid, -1string);
                }
                else
                {
                    
SendClientMessage(playerid, -1"longe da porta!");
                    return 
1;
                }
            }
        }
    }
        
    return 
1;

Reply
#2

Tente isso

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new string[128];

    // Entrar Casa
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(!pInfo[playerid][dentrocasa])
        {
            new timestamp = GetTickCount();
            if(timestamp - inhousepickup[playerid] > 1000)
            {
                return 1;
            }

            format(STRX, sizeof(STRX), "Casaid %d", playericonhouse[playerid]);
            GetPlayerName(playerid, pInfo[playerid][Nome], 24);
            if(hInfo[playericonhouse[playerid]][SemInt] == 1) return SendClientMessage(playerid, -1, "Casa sem portas");

            if(strcmp(hInfo[playericonhouse[playerid]][Dono], pInfo[playerid][Nome], true) == 0)
            {
                playerworld[playerid] = GetPlayerVirtualWorld(playerid);
                SetPlayerVirtualWorld(playerid, hInfo[playericonhouse[playerid]][Virtualworld]);
                SetPlayerInterior(playerid, hInfo[playericonhouse[playerid]][Interior]);
                SetPlayerPos(playerid, hInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]);
                playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior];
                pInfo[playerid][dentrocasa] = true;
                format(string, sizeof(string), "Bem vindo a sua casa", hInfo[playericonhouse[playerid]][ID]);
                SendClientMessage(playerid, -1, string);
                return 1;
            }

            if(hInfo[playericonhouse[playerid]][Locked] == true) return SendClientMessage(playerid, -1, "Essa casa estб trancada");

            playerworld[playerid] = GetPlayerVirtualWorld(playerid);
            SetPlayerVirtualWorld(playerid, hInfo[playericonhouse[playerid]][Virtualworld]);
            SetPlayerInterior(playerid, hInfo[playericonhouse[playerid]][Interior]);
            SetPlayerPos(playerid, hInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]);
            playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior];
            pInfo[playerid][dentrocasa] = true;
            format(string, sizeof(string), "Bem vindo б CASA ID %d", hInfo[playericonhouse[playerid]][ID]);
            SendClientMessage(playerid, -1, string);
        }
        else
        {
            if(GetPlayerInterior(playerid) == playerinterior[playerid])
            {
                if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]))
                {
                    SetPlayerPos(playerid, hInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony],hInfo[playericonhouse[playerid]][iconz]);
                    SetPlayerInterior(playerid, playerworld[playerid]);
                    SetPlayerVirtualWorld(playerid, 0);
                    pInfo[playerid][dentrocasa] = false;
                    format(string, sizeof(STRX), "Vocк saiu da casa %d.", hInfo[playericonhouse[playerid]][ID]);
                    SendClientMessage(playerid, -1, string);
                }
                else
                {
                    SendClientMessage(playerid, -1, "Vocк estб longe da porta!");
                    return 1;
                }
            }
        }
    }

    // Entrar Empresa
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(!pInfo[playerid][dentroEmpresa])
        {
            new timestamp = GetTickCount();
            if(timestamp - inEmpresapickup[playerid] > 1000)
            {
                return 1;
            }

            format(STRX, sizeof(STRX), "Empresa ID : %d", playericonEmpresa[playerid]);
            GetPlayerName(playerid, pInfo[playerid][Nome], 24);
            if(eInfo[playericonEmpresa[playerid]][eSemInt] == 1) return SendClientMessage(playerid, -1, "nгo tem portas!");

            if(strcmp(eInfo[playericonEmpresa[playerid]][eDonoEmpresa], pInfo[playerid][Nome], true) == 0)
            {
                playerworld[playerid] = GetPlayerVirtualWorld(playerid);
                SetPlayerVirtualWorld(playerid, eInfo[playericonEmpresa[playerid]][eVirtualworld]);
                SetPlayerInterior(playerid, eInfo[playericonEmpresa[playerid]][eInterior]);
                SetPlayerPos(playerid, eInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]);
                playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior];
                pInfo[playerid][dentroEmpresa] = true;
                format(string, sizeof(string), "Sua Empresa de ID : %d ", eInfo[playericonEmpresa[playerid]][eID]);
                SendClientMessage(playerid, -1, string);
                return 1;
            }

            if(eInfo[playericonEmpresa[playerid]][eLocked] == true) return SendClientMessage(playerid, -1, "Empresa estб fechada");

            playerworld[playerid] = GetPlayerVirtualWorld(playerid);
            SetPlayerVirtualWorld(playerid, eInfo[playericonEmpresa[playerid]][eVirtualworld]);
            SetPlayerInterior(playerid, eInfo[playericonEmpresa[playerid]][eInterior]);
            SetPlayerPos(playerid, eInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]);
            playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior];
            pInfo[playerid][dentroEmpresa] = true;
            format(string, sizeof(string), "Empresa ID : %d.", eInfo[playericonEmpresa[playerid]][eID]);
            SendClientMessage(playerid, -1, string);
        }
        else
        {
            if(GetPlayerInterior(playerid) == playerinterior[playerid])
            {
                if(IsPlayerInRangeOfPoint(playerid, 2.0, eInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]))
                {
                    SetPlayerPos(playerid, eInfo[playericonEmpresa[playerid]][eiconx], eInfo[playericonEmpresa[playerid]][eicony],eInfo[playericonEmpresa[playerid]][eiconz]);
                    SetPlayerInterior(playerid, playerworld[playerid]);
                    SetPlayerVirtualWorld(playerid, 0);
                    pInfo[playerid][dentroEmpresa] = false;
                    format(string, sizeof(STRX), "saiu da Empresa ID : %d.", eInfo[playericonEmpresa[playerid]][eID]);
                    SendClientMessage(playerid, -1, string);
                }
                else
                {
                    SendClientMessage(playerid, -1, "longe da porta!");
                    return 1;
                }
            }
        }
    }

    return 1;
}
Reply
#3

Eu agradeзo pela ajuda KoloradO, mas ainda tenho o mesmo problema.

Edit : Se eu mudar a tecla para uma tecla que nгo esteja em uso eu consigo entrar na empresa.

exemplo
PHP код:
// entrar casa
if(newkeys == KEY_SECONDARY_ATTACK)

   
// Cod
}
// entrar empresa
if(newkeys == KEY_SPRINT)
{
   
// Cod

Reply
#4

Tente agora :
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
string[128];
    if(
newkeys == KEY_SECONDARY_ATTACK
        { 
            if(!
pInfo[playerid][dentrocasa]) 
            { 
                new 
timestamp GetTickCount(); 
                if(
timestamp inhousepickup[playerid] > 1000
                { 
                    return 
1
                } 
                 
                
format(STRXsizeof(STRX), "Casaid %d"playericonhouse[playerid]); 
                
GetPlayerName(playeridpInfo[playerid][Nome], 24); 
                if(
hInfo[playericonhouse[playerid]][SemInt] == 1) return SendClientMessage(playerid, -1"Casa sem portas"); 
                 
                if(
strcmp(hInfo[playericonhouse[playerid]][Dono], pInfo[playerid][Nome], true) == 0
                { 
                    
playerworld[playerid] = GetPlayerVirtualWorld(playerid); 
                    
SetPlayerVirtualWorld(playeridhInfo[playericonhouse[playerid]][Virtualworld]); 
                    
SetPlayerInterior(playeridhInfo[playericonhouse[playerid]][Interior]); 
                    
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]); 
                    
playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior]; 
                    
pInfo[playerid][dentrocasa] = true
                    
format(stringsizeof(string), "Bem vindo a sua casa"hInfo[playericonhouse[playerid]][ID]); 
                    
SendClientMessage(playerid, -1string); 
                    return 
1
                } 
                 
                if(
hInfo[playericonhouse[playerid]][Locked] == true) return SendClientMessage(playerid, -1"Essa casa estб trancada"); 
                 
                
playerworld[playerid] = GetPlayerVirtualWorld(playerid); 
                
SetPlayerVirtualWorld(playeridhInfo[playericonhouse[playerid]][Virtualworld]); 
                
SetPlayerInterior(playeridhInfo[playericonhouse[playerid]][Interior]); 
                
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]); 
                
playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior]; 
                
pInfo[playerid][dentrocasa] = true
                
format(stringsizeof(string), "Bem vindo б CASA ID %d"hInfo[playericonhouse[playerid]][ID]); 
                
SendClientMessage(playerid, -1string); 
            } 
            else 
            { 
                if(
GetPlayerInterior(playerid) == playerinterior[playerid]) 
                { 
                    if(
IsPlayerInRangeOfPoint(playerid2.0hInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ])) 
                    { 
                        
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony],hInfo[playericonhouse[playerid]][iconz]); 
                        
SetPlayerInterior(playeridplayerworld[playerid]); 
                        
SetPlayerVirtualWorld(playerid0); 
                        
pInfo[playerid][dentrocasa] = false
                        
format(stringsizeof(STRX), "Vocк saiu da casa %d."hInfo[playericonhouse[playerid]][ID]); 
                        
SendClientMessage(playerid, -1string); 
                    } 
                    else 
                    { 
                        
SendClientMessage(playerid, -1"Vocк estб longe da porta!"); 
                        return 
1
                    } 
                } 
            }
            
            if(!
pInfo[playerid][dentroEmpresa]) 
            { 
                new 
timestamp GetTickCount(); 
                if(
timestamp inEmpresapickup[playerid] > 1000
                {     
                    return 
1
                } 
                 
                
format(STRXsizeof(STRX), "Empresa ID : %d"playericonEmpresa[playerid]); 
                
GetPlayerName(playeridpInfo[playerid][Nome], 24); 
                if(
eInfo[playericonEmpresa[playerid]][eSemInt] == 1) return SendClientMessage(playerid, -1"nгo tem portas!"); 
                 
                if(
strcmp(eInfo[playericonEmpresa[playerid]][eDonoEmpresa], pInfo[playerid][Nome], true) == 0
                { 
                    
playerworld[playerid] = GetPlayerVirtualWorld(playerid); 
                    
SetPlayerVirtualWorld(playerideInfo[playericonEmpresa[playerid]][eVirtualworld]); 
                    
SetPlayerInterior(playerideInfo[playericonEmpresa[playerid]][eInterior]); 
                    
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]); 
                    
playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior]; 
                    
pInfo[playerid][dentroEmpresa] = true
                    
format(stringsizeof(string), "Sua Empresa de ID : %d "eInfo[playericonEmpresa[playerid]][eID]); 
                    
SendClientMessage(playerid, -1string); 
                    return 
1
                } 
                 
                if(
eInfo[playericonEmpresa[playerid]][eLocked] == true) return SendClientMessage(playerid, -1"Empresa estб fechada"); 
                 
                
playerworld[playerid] = GetPlayerVirtualWorld(playerid); 
                
SetPlayerVirtualWorld(playerideInfo[playericonEmpresa[playerid]][eVirtualworld]); 
                
SetPlayerInterior(playerideInfo[playericonEmpresa[playerid]][eInterior]); 
                
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]); 
                
playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior]; 
                
pInfo[playerid][dentroEmpresa] = true
                
format(stringsizeof(string), "Empresa ID : %d."eInfo[playericonEmpresa[playerid]][eID]); 
                
SendClientMessage(playerid, -1string); 
            } 
            else 
            { 
                if(
GetPlayerInterior(playerid) == playerinterior[playerid]) 
                { 
                    if(
IsPlayerInRangeOfPoint(playerid2.0eInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ])) 
                    { 
                        
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eiconx], eInfo[playericonEmpresa[playerid]][eicony],eInfo[playericonEmpresa[playerid]][eiconz]); 
                        
SetPlayerInterior(playeridplayerworld[playerid]); 
                        
SetPlayerVirtualWorld(playerid0); 
                        
pInfo[playerid][dentroEmpresa] = false
                        
format(stringsizeof(STRX), "saiu da Empresa ID : %d."eInfo[playericonEmpresa[playerid]][eID]); 
                        
SendClientMessage(playerid, -1string); 
                    } 
                    else 
                    { 
                        
SendClientMessage(playerid, -1"longe da porta!"); 
                        return 
1
                    } 
                } 
            } 
        } 
    return 
1;      

Reply
#5

Primeiramente, nгo hб porque colocar duas vezes a mesma condicional, ou seja, use apenas um "if(newkeys & KEY_SECONDARY_ATTACK)".
Outra: Meu palpite й de que o seu cуdigo estб sendo interrompido por algum 'return 1;' escrito no cуdigo da casa.
Analise bem e se possнvel retire os 'return 1;' possнveis de serem removidos.
Reply
#6

Quote:
Originally Posted by FerrariL
Посмотреть сообщение
Tente agora :
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
string[128];
    if(
newkeys == KEY_SECONDARY_ATTACK
        { 
            if(!
pInfo[playerid][dentrocasa]) 
            { 
                new 
timestamp GetTickCount(); 
                if(
timestamp inhousepickup[playerid] > 1000
                { 
                    return 
1
                } 
                 
                
format(STRXsizeof(STRX), "Casaid %d"playericonhouse[playerid]); 
                
GetPlayerName(playeridpInfo[playerid][Nome], 24); 
                if(
hInfo[playericonhouse[playerid]][SemInt] == 1) return SendClientMessage(playerid, -1"Casa sem portas"); 
                 
                if(
strcmp(hInfo[playericonhouse[playerid]][Dono], pInfo[playerid][Nome], true) == 0
                { 
                    
playerworld[playerid] = GetPlayerVirtualWorld(playerid); 
                    
SetPlayerVirtualWorld(playeridhInfo[playericonhouse[playerid]][Virtualworld]); 
                    
SetPlayerInterior(playeridhInfo[playericonhouse[playerid]][Interior]); 
                    
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]); 
                    
playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior]; 
                    
pInfo[playerid][dentrocasa] = true
                    
format(stringsizeof(string), "Bem vindo a sua casa"hInfo[playericonhouse[playerid]][ID]); 
                    
SendClientMessage(playerid, -1string); 
                    return 
1
                } 
                 
                if(
hInfo[playericonhouse[playerid]][Locked] == true) return SendClientMessage(playerid, -1"Essa casa estб trancada"); 
                 
                
playerworld[playerid] = GetPlayerVirtualWorld(playerid); 
                
SetPlayerVirtualWorld(playeridhInfo[playericonhouse[playerid]][Virtualworld]); 
                
SetPlayerInterior(playeridhInfo[playericonhouse[playerid]][Interior]); 
                
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]); 
                
playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior]; 
                
pInfo[playerid][dentrocasa] = true
                
format(stringsizeof(string), "Bem vindo б CASA ID %d"hInfo[playericonhouse[playerid]][ID]); 
                
SendClientMessage(playerid, -1string); 
            } 
            else 
            { 
                if(
GetPlayerInterior(playerid) == playerinterior[playerid]) 
                { 
                    if(
IsPlayerInRangeOfPoint(playerid2.0hInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ])) 
                    { 
                        
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony],hInfo[playericonhouse[playerid]][iconz]); 
                        
SetPlayerInterior(playeridplayerworld[playerid]); 
                        
SetPlayerVirtualWorld(playerid0); 
                        
pInfo[playerid][dentrocasa] = false
                        
format(stringsizeof(STRX), "Vocк saiu da casa %d."hInfo[playericonhouse[playerid]][ID]); 
                        
SendClientMessage(playerid, -1string); 
                    } 
                    else 
                    { 
                        
SendClientMessage(playerid, -1"Vocк estб longe da porta!"); 
                        return 
1
                    } 
                } 
            }
            
            if(!
pInfo[playerid][dentroEmpresa]) 
            { 
                new 
timestamp GetTickCount(); 
                if(
timestamp inEmpresapickup[playerid] > 1000
                {     
                    return 
1
                } 
                 
                
format(STRXsizeof(STRX), "Empresa ID : %d"playericonEmpresa[playerid]); 
                
GetPlayerName(playeridpInfo[playerid][Nome], 24); 
                if(
eInfo[playericonEmpresa[playerid]][eSemInt] == 1) return SendClientMessage(playerid, -1"nгo tem portas!"); 
                 
                if(
strcmp(eInfo[playericonEmpresa[playerid]][eDonoEmpresa], pInfo[playerid][Nome], true) == 0
                { 
                    
playerworld[playerid] = GetPlayerVirtualWorld(playerid); 
                    
SetPlayerVirtualWorld(playerideInfo[playericonEmpresa[playerid]][eVirtualworld]); 
                    
SetPlayerInterior(playerideInfo[playericonEmpresa[playerid]][eInterior]); 
                    
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]); 
                    
playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior]; 
                    
pInfo[playerid][dentroEmpresa] = true
                    
format(stringsizeof(string), "Sua Empresa de ID : %d "eInfo[playericonEmpresa[playerid]][eID]); 
                    
SendClientMessage(playerid, -1string); 
                    return 
1
                } 
                 
                if(
eInfo[playericonEmpresa[playerid]][eLocked] == true) return SendClientMessage(playerid, -1"Empresa estб fechada"); 
                 
                
playerworld[playerid] = GetPlayerVirtualWorld(playerid); 
                
SetPlayerVirtualWorld(playerideInfo[playericonEmpresa[playerid]][eVirtualworld]); 
                
SetPlayerInterior(playerideInfo[playericonEmpresa[playerid]][eInterior]); 
                
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]); 
                
playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior]; 
                
pInfo[playerid][dentroEmpresa] = true
                
format(stringsizeof(string), "Empresa ID : %d."eInfo[playericonEmpresa[playerid]][eID]); 
                
SendClientMessage(playerid, -1string); 
            } 
            else 
            { 
                if(
GetPlayerInterior(playerid) == playerinterior[playerid]) 
                { 
                    if(
IsPlayerInRangeOfPoint(playerid2.0eInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ])) 
                    { 
                        
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eiconx], eInfo[playericonEmpresa[playerid]][eicony],eInfo[playericonEmpresa[playerid]][eiconz]); 
                        
SetPlayerInterior(playeridplayerworld[playerid]); 
                        
SetPlayerVirtualWorld(playerid0); 
                        
pInfo[playerid][dentroEmpresa] = false
                        
format(stringsizeof(STRX), "saiu da Empresa ID : %d."eInfo[playericonEmpresa[playerid]][eID]); 
                        
SendClientMessage(playerid, -1string); 
                    } 
                    else 
                    { 
                        
SendClientMessage(playerid, -1"longe da porta!"); 
                        return 
1
                    } 
                } 
            } 
        } 
    return 
1;      

Nгo funciona, mas agradeзo.

Eu elaborei um teste para tentar chegar no erro, criei uma variбvel global e um comando para modificar o valor dela.

PHP код:

new testeSet;
CMD:set(playerid)
{
    
testeSet 1;
    
printf("testeSet : %d"testeSet);

Depois eu adicionei mais uma condiзгo no if

PHP код:
// entrar casa
if(!pInfo[playerid][dentrocasa] && testeSet == 0)
// entrar empresa
if(!pInfo[playerid][dentroEmpresa] && testeSet == 1
Entгo usando o comando, eu consigo entrar na empresa, mas nгo encontro o erro.
Reply
#7

Quote:
Originally Posted by Lontresca
Посмотреть сообщение
Nгo funciona, mas agradeзo.

Eu elaborei um teste para tentar chegar no erro, criei uma variбvel global e um comando para modificar o valor dela.

PHP код:

new testeSet;
CMD:set(playerid)
{
    
testeSet 1;
    
printf("testeSet : %d"testeSet);

Depois eu adicionei mais uma condiзгo no if

PHP код:
// entrar casa
if(!pInfo[playerid][dentrocasa] && testeSet == 0)
// entrar empresa
if(!pInfo[playerid][dentroEmpresa] && testeSet == 1
Entгo usando o comando, eu consigo entrar na empresa, mas nгo encontro o erro.
Vocк tentou o que eu sugeri?
Reply
#8

Faзa um debug no cуdigo,Nгo precisa de usar 2 condicionais usa o comando que te passei e vai verificando o valor das variбveis e etc... Vai comentando as primeiras linhas e testa InGame,desse modo vocк pode achar o erro.
Reply
#9

Quote:
Originally Posted by JohnBlack
Посмотреть сообщение
Vocк tentou o que eu sugeri?
Sim tentei, estou usando apenas umas vez o if(newkeys & KEY_SECONDARY_ATTACK) e dei uma analisada nos return. O que me parece aqui й, quando eu aperto o enter/f as duas variбveis estгo falsa (pInfo[playerid][dentrocasa]) , (pInfo[playerid][dentroEmpresa]) entгo ele vai chamar as duas funзхes juntos.

Estou tentando elaborar uma forma de que antes de chegar a as variбvel (pInfo[playerid][dentrocasa]) , (pInfo[playerid][dentroEmpresa]) ele verifique se o jogador esta em cima da pickup.


exemplo.
PHP код:

if(playerid estб na pickup casa)
{
   if(!
pInfo[playerid][dentrocasa])
   {
     
// code
   
}
}
if(
playerid estб na pickup empresa)
{
   if(!
pInfo[playerid][dentroEmpresa])
   {
     
// code
   
}

Acredito que essa seja a soluзгo....

Edit: Resolvido do seguinte modo , nгo sei se й a melhor forma, se alguйm achar um modo melhor eu agradeзo

PHP код:

// OnPlayerKeyStateChange
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
string[128];
        
    if(
newkeys KEY_SECONDARY_ATTACK)
    {
        new 
timestamp GetTickCount();
        
//     =-=-=-=-=-=-=-=-=-=-=-= Entrar Casa =-=-=-=-=-=-=-=-=-=-=-=
        
if(!pInfo[playerid][dentrocasa] && timestamp inhousepickup[playerid] < 1000)
        {    
            
SendClientMessage(playerid, -1" CASA ");
            if(
timestamp inhousepickup[playerid] > 1000)
            {
                return 
1;
            }
            
            
format(STRXsizeof(STRX), "Casaid %d"playericonhouse[playerid]);
            
GetPlayerName(playeridpInfo[playerid][Nome], 24);
            if(
hInfo[playericonhouse[playerid]][SemInt] == 1) return SendClientMessage(playerid, -1"Casa sem portas");
            
            if(
strcmp(hInfo[playericonhouse[playerid]][Dono], pInfo[playerid][Nome], true) == 0)
            {
                
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
                
SetPlayerVirtualWorld(playeridhInfo[playericonhouse[playerid]][Virtualworld]);
                
SetPlayerInterior(playeridhInfo[playericonhouse[playerid]][Interior]);
                
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]);
                
playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior];
                
pInfo[playerid][dentrocasa] = true;
                
format(stringsizeof(string), "Bem vindo a sua casa"hInfo[playericonhouse[playerid]][ID]);
                
SendClientMessage(playerid, -1string);
                return 
1;
            }
            
            if(
hInfo[playericonhouse[playerid]][Locked] == true) return SendClientMessage(playerid, -1"Essa casa estб trancada"); 
            
            
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
            
SetPlayerVirtualWorld(playeridhInfo[playericonhouse[playerid]][Virtualworld]);
            
SetPlayerInterior(playeridhInfo[playericonhouse[playerid]][Interior]);
            
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]);
            
playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior];
            
pInfo[playerid][dentrocasa] = true;
            
format(stringsizeof(string), "Bem vindo б CASA ID %d"hInfo[playericonhouse[playerid]][ID]);
            
SendClientMessage(playerid, -1string);
        }
        else
        {
            if(
GetPlayerInterior(playerid) == playerinterior[playerid] && pInfo[playerid][dentrocasa])
            {
                if(
IsPlayerInRangeOfPoint(playerid2.0hInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]))
                {
                    
SetPlayerPos(playeridhInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony],hInfo[playericonhouse[playerid]][iconz]);
                    
SetPlayerInterior(playeridplayerworld[playerid]);
                    
SetPlayerVirtualWorld(playerid0);
                    
pInfo[playerid][dentrocasa] = false;
                    
format(stringsizeof(STRX), "Vocк saiu da casa %d."hInfo[playericonhouse[playerid]][ID]);
                    
SendClientMessage(playerid, -1string);
                }
                else
                {
                    
SendClientMessage(playerid, -1"Vocк estб longe da porta!");
                    return 
1;
                }
            }
        }
        
//     =-=-=-=-=-=-=-=-=-=-=-= Entrar Casa End =-=-=-=-=-=-=-=-=-=-=-=
        
if(!pInfo[playerid][dentroEmpresa] && timestamp inEmpresapickup[playerid] < 1000)
        {    
            
SendClientMessage(playerid, -1" Empresa ");
            if(
timestamp inEmpresapickup[playerid] > 1000)
            {    
                return 
1;
            }
            
            
format(STRXsizeof(STRX), "Empresa ID : %d"playericonEmpresa[playerid]);
            
GetPlayerName(playeridpInfo[playerid][Nome], 24);
            if(
eInfo[playericonEmpresa[playerid]][eSemInt] == 1) return SendClientMessage(playerid, -1"nгo tem portas!");
            
            if(
strcmp(eInfo[playericonEmpresa[playerid]][eDonoEmpresa], pInfo[playerid][Nome], true) == 0)
            {
                
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
                
SetPlayerVirtualWorld(playerideInfo[playericonEmpresa[playerid]][eVirtualworld]);
                
SetPlayerInterior(playerideInfo[playericonEmpresa[playerid]][eInterior]);
                
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]);
                
playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior];
                
pInfo[playerid][dentroEmpresa] = true;
                
format(stringsizeof(string), "Sua Empresa de ID : %d "eInfo[playericonEmpresa[playerid]][eID]);
                
SendClientMessage(playerid, -1string);
                return 
1;
            }
            
            if(
eInfo[playericonEmpresa[playerid]][eLocked] == true) return SendClientMessage(playerid, -1"Empresa estб fechada"); 
            
            
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
            
SetPlayerVirtualWorld(playerideInfo[playericonEmpresa[playerid]][eVirtualworld]);
            
SetPlayerInterior(playerideInfo[playericonEmpresa[playerid]][eInterior]);
            
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]);
            
playerinterior[playerid] = eInfo[playericonEmpresa[playerid]][eInterior];
            
pInfo[playerid][dentroEmpresa] = true;
            
format(stringsizeof(string), "Empresa ID : %d."eInfo[playericonEmpresa[playerid]][eID]);
            
SendClientMessage(playerid, -1string);
        }
        else
        {
            if(
GetPlayerInterior(playerid) == playerinterior[playerid] && pInfo[playerid][dentroEmpresa])
            {
                if(
IsPlayerInRangeOfPoint(playerid2.0eInfo[playericonEmpresa[playerid]][eInteriorX], eInfo[playericonEmpresa[playerid]][eInteriorY], eInfo[playericonEmpresa[playerid]][eInteriorZ]))
                {
                    
SetPlayerPos(playerideInfo[playericonEmpresa[playerid]][eiconx], eInfo[playericonEmpresa[playerid]][eicony],eInfo[playericonEmpresa[playerid]][eiconz]);
                    
SetPlayerInterior(playeridplayerworld[playerid]);
                    
SetPlayerVirtualWorld(playerid0);
                    
pInfo[playerid][dentroEmpresa] = false;
                    
format(stringsizeof(STRX), "Vocк saiu da Empresa ID : %d."eInfo[playericonEmpresa[playerid]][eID]);
                    
SendClientMessage(playerid, -1string);
                }
                else
                {
                    
SendClientMessage(playerid, -1"Vocк estб longe da porta");
                    return 
1;
                }
            }
        }
    }
        
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)