[Ajuda] criar um else para desativar
#1

quero criar um else nesse comando para ativar e desativar:
PHP код:
            if(listitem == 3)
            {
                
ResetPlayerWeaponsEx(playerid);
                
SetPlayerAttachedObject(playerid,1,19142,1,0.1,0.05,0.0,0.0,0.0,0.0);
                
SetPlayerAttachedObject(playerid,2,19141,2,0.11,0.0,0.0,0.0,0.0,0.0);
                
SetPlayerAttachedObject(playerid,3,18637,13,0.35,0.0,0.0,0.0,0.0,180.0);
                
GivePlayerWeapon(playerid3310);
                
SendClientMessage(playerid,COLOR_RED,"Vocк equipou sua arma de shock !");
                
SendClientMessage(playerid,COLOR_RED,"Obs: Sу use no procurado se ele tentar fugir, caso contrбrio vocк serб punido !");
                
TogglePlayerControllable(playerid1);
            } 
igual esse para clicar nele ativa e se clicar dinovo desativa:
PHP код:
            if(listitem == 2)
            {
                if(
GetPlayerOrg(playerid) == 1)
                {
                    if(
OnDuty[playerid] != 1)
                    {
                         
SendClientMessage(playeridCOLOR_GREY"Vocк nгo Bateu o cartгo!");
                         return 
1;
                    }
                    if(
rocamativado[playerid] == 0)
                    {
                         
skinrocam[playerid] = GetPlayerSkin(playerid);
                         
SetPlayerSkin(playerid284);
                         
JogadorInfo[playerid][pSkin] = 284;
                         
SendClientMessage(playeridCOLOR_RED"Vocк ativou o modo ROCAM !");
                         
rocamativado[playerid] = 1;
                    }
                    else if(
rocamativado[playerid] == 1)
                    {
                       
SetPlayerSkin(playeridskinrocam[playerid]);
                       
JogadorInfo[playerid][pSkin] = skinrocam[playerid];
                       
SendClientMessage(playeridCOLOR_RED"Vocк desativou o modo ROCAM !");
                       
rocamativado[playerid] = 0;
                    }
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_RED"Vocк nгo й da Policia Militar !");
                    return 
1;
                }
            } 
Reply
#2

Й simples amigo, vou tentar te ajudar, no topo da GM vocк adciona:
Код:
new ArmaShock[MAX_PLAYERS]
Ai no OnPlayerDialogResponse vocк muda assim:
Код:
  if(listitem == 3)
            {
                if(ArmaShock[playerid] == false)
                {
                ResetPlayerWeaponsEx(playerid);
                SetPlayerAttachedObject(playerid,1,19142,1,0.1,0.05,0.0,0.0,0.0,0.0);
                SetPlayerAttachedObject(playerid,2,19141,2,0.11,0.0,0.0,0.0,0.0,0.0);
                SetPlayerAttachedObject(playerid,3,18637,13,0.35,0.0,0.0,0.0,0.0,180.0);
                GivePlayerWeapon(playerid, 33, 10);
                SendClientMessage(playerid,COLOR_RED,"Vocк equipou sua arma de shock !");
                SendClientMessage(playerid,COLOR_RED,"Obs: Sу use no procurado se ele tentar fugir, caso contrбrio vocк serб punido !");
                TogglePlayerControllable(playerid, 1);
                ArmaShock[playerid] == true;
                }
                else
                {
                    //Aqui vocк coloca as funзхes que vгo ocorrer se ele jб tiver com a arma de shock, ou seja, aqui vocк desativa a arma de shock pra ele
                 ArmaShock[playerid] == false;
                 }
            }
Reply
#3

PHP код:
new shockativado[MAX_PLAYERS]; // inicio do GM junto as variaveis
            
if(listitem == 3)
            {
                if(
shockativado[playerid] == 0)
                {
                    
ResetPlayerWeaponsEx(playerid);
                    
SetPlayerAttachedObject(playerid,1,19142,1,0.1,0.05,0.0,0.0,0.0,0.0);
                    
SetPlayerAttachedObject(playerid,2,19141,2,0.11,0.0,0.0,0.0,0.0,0.0);
                    
SetPlayerAttachedObject(playerid,3,18637,13,0.35,0.0,0.0,0.0,0.0,180.0);
                    
GivePlayerWeapon(playerid3310);
                    
SendClientMessage(playerid,COLOR_RED,"Vocк equipou sua arma de shock !");
                    
SendClientMessage(playerid,COLOR_RED,"Obs: Sу use no procurado se ele tentar fugir, caso contrбrio vocк serб punido !");
                    
TogglePlayerControllable(playerid1);
                    
shockativado[playerid] = 1;
                    } else {
                     
ResetPlayerWeaponsEx(playerid);
                        
RemovePlayerAttachedObject(playerid1);
                        
RemovePlayerAttachedObject(playerid2);
                        
RemovePlayerAttachedObject(playerid3);
                     
shockativado[playerid] = 0;
                }
            } 
Reply
#4

Quote:
Originally Posted by DiegoLeo
Посмотреть сообщение
Й simples amigo, vou tentar te ajudar, no topo da GM vocк adciona:
Код:
new ArmaShock[MAX_PLAYERS]
pawn Код:
new bool:ArmaShock[MAX_PLAYERS];
Reply
#5

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
pawn Код:
new bool:ArmaShock[MAX_PLAYERS];
Obrigado por corrigir, estou comeзando a pouco tempo em pawn. Vou dar uma lida melhor sobre arrays booleans e tudo mais. Vlw man
Reply
#6

PHP код:
C:\Users\Usuario\Desktop\gm\gamemodes\BPF.pwn(5371) : warning 215expression has no effect
C
:\Users\Usuario\Desktop\gm\gamemodes\BPF.pwn(5380) : warning 215expression has no effect
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
2 Warnings

fiz assim:
PHP код:
            if(listitem == 3)
            {
                if(
ArmaShock[playerid] == false)
                {
                
ResetPlayerWeaponsEx(playerid);
                
SetPlayerAttachedObject(playerid,1,19142,1,0.1,0.05,0.0,0.0,0.0,0.0);
                
SetPlayerAttachedObject(playerid,2,19141,2,0.11,0.0,0.0,0.0,0.0,0.0);
                
SetPlayerAttachedObject(playerid,3,18637,13,0.35,0.0,0.0,0.0,0.0,180.0);
                
GivePlayerWeapon(playerid3310);
                
SendClientMessage(playerid,COLOR_RED,"Vocк equipou sua arma de shock !");
                
SendClientMessage(playerid,COLOR_RED,"Obs: Sу use no procurado se ele tentar fugir, caso contrбrio vocк serб punido !");
                
TogglePlayerControllable(playerid1);
                
ArmaShock[playerid] == true;
                }
                else
                {
                 
ResetPlayerWeaponsEx(playerid);
                 
RemovePlayerAttachedObject(playerid1);
                 
RemovePlayerAttachedObject(playerid2);
                 
RemovePlayerAttachedObject(playerid3);
                 
SendClientMessage(playerid,COLOR_RED,"Vocк Desequipou sua arma de shock !");
                 
ArmaShock[playerid] == false;
                 }
            } 
Reply
#7

pawn Код:
if(listitem == 3)
            {
                if(ArmaShock[playerid] == false)
                {
                ResetPlayerWeaponsEx(playerid);
                SetPlayerAttachedObject(playerid,1,19142,1,0.1,0.05,0.0,0.0,0.0,0.0);
                SetPlayerAttachedObject(playerid,2,19141,2,0.11,0.0,0.0,0.0,0.0,0.0);
                SetPlayerAttachedObject(playerid,3,18637,13,0.35,0.0,0.0,0.0,0.0,180.0);
                GivePlayerWeapon(playerid, 33, 10);
                SendClientMessage(playerid,COLOR_RED,"Vocк equipou sua arma de shock !");
                SendClientMessage(playerid,COLOR_RED,"Obs: Sу use no procurado se ele tentar fugir, caso contrбrio vocк serб punido !");
                TogglePlayerControllable(playerid, 1);
                ArmaShock[playerid] = true;
                }
                else
                {
                 ResetPlayerWeaponsEx(playerid);
                 RemovePlayerAttachedObject(playerid, 1);
                 RemovePlayerAttachedObject(playerid, 2);
                 RemovePlayerAttachedObject(playerid, 3);
                 SendClientMessage(playerid,COLOR_RED,"Vocк Desequipou sua arma de shock !");
                 ArmaShock[playerid] = false;
                 }
            }
Reply
#8

Ae funcionou perefeitamente Obrigado a todos que ajudaram como dar rep?
Reply
#9

sу dar um clique na estrela de quem vocк quer da reputaзгo.
Reply
#10

ata acheii +rep ai pra vcs vlww
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)