[Ajuda] Armas por score
#1

Estou tentando colocar pra o player spawnar com tais armas conforme o score, porem, quando o player loga e spawna de primeira, ele spawna somente com uma arma, nгo com as outras que deveria ser pelo seu nнvel, as outras armas aparecem somente depois que o player morre pela primeira vez.

Exmplo:

PHP код:
Tenho 1000 killsdeveria aparecer
                GivePlayerWeapon
(playerid24500);
                
GivePlayerWeapon(playerid27500);
                
GivePlayerWeapon(playerid29500);
                
GivePlayerWeapon(playerid3490);
                
GivePlayerWeapon(playerid311500);
                
SetPlayerArmour(playerid100);
                
GivePlayerWeapon(playerid375); 
Mas aparece sу uma Desert Eagle (ARMA ID 24), somente depois que eu morro pela primeira vez aparece as armas citadas a cima nos spawns.

Code:
PHP код:
Em "public OnPlayerSpawn"
DarArmas(playerid); 
No final do gamemode:
PHP код:
DarArmas(playerid)
{
    if(
IsPlayerConnected(playerid))
    {
            if(
GetPlayerScore(playerid) >= && GetPlayerScore(playerid) <= 30){
                
GivePlayerWeapon(playerid24500);
            }
               if(
GetPlayerScore(playerid) >= 30 && GetPlayerScore(playerid) <= 80){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid25500);
            }
               if(
GetPlayerScore(playerid) >= 80 && GetPlayerScore(playerid) <= 150){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid25500);
                
GivePlayerWeapon(playerid29500);
            }
               if(
GetPlayerScore(playerid) >= 150 && GetPlayerScore(playerid) <= 230){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid25500);
                
GivePlayerWeapon(playerid29500);
            }
               if(
GetPlayerScore(playerid) >= 230 && GetPlayerScore(playerid) <= 320){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid25500);
                
GivePlayerWeapon(playerid29500);
                
GivePlayerWeapon(playerid301500);
                
SetPlayerArmour(playerid20);
            }
               if(
GetPlayerScore(playerid) >= 320 && GetPlayerScore(playerid) <= 450){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid25500);
                
GivePlayerWeapon(playerid29500);
                
GivePlayerWeapon(playerid311500);
                
SetPlayerArmour(playerid20);
            }
               if(
GetPlayerScore(playerid) >= 450 && GetPlayerScore(playerid) <= 700){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid27500);
                
GivePlayerWeapon(playerid29500);
                
GivePlayerWeapon(playerid311500);
                
SetPlayerArmour(playerid20);
            }
               if(
GetPlayerScore(playerid) >= 700 && GetPlayerScore(playerid) <= 1000){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid27500);
                
GivePlayerWeapon(playerid29500);
                
GivePlayerWeapon(playerid311500);
                
SetPlayerArmour(playerid60);
            }
               if(
GetPlayerScore(playerid) >= 1000 && GetPlayerScore(playerid) <= 1337){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid27500);
                
GivePlayerWeapon(playerid29500);
                
GivePlayerWeapon(playerid3490);
                
GivePlayerWeapon(playerid311500);
                
SetPlayerArmour(playerid60);
            }
               if(
GetPlayerScore(playerid) >= 1337 && GetPlayerScore(playerid) <= 9999999){
                
GivePlayerWeapon(playerid24500);
                
GivePlayerWeapon(playerid27500);
                
GivePlayerWeapon(playerid29500);
                
GivePlayerWeapon(playerid3490);
                
GivePlayerWeapon(playerid311500);
                
SetPlayerArmour(playerid100);
                
GivePlayerWeapon(playerid375);
        }
    }
    return 
1;

Da um help ai pls :V
Reply
#2

Spawnar pela primeira vez que vocк fala й ao player se conectar correto? Se for isso й sу o colocar DarArmas(playerid) dentro do OnPlayerConnect tambйm, e pronto ele vai spawnar com as armas coerentes ao score dele...
Reply
#3

Quote:
Originally Posted by GunnerCoder
Посмотреть сообщение
Spawnar pela primeira vez que vocк fala й ao player se conectar correto? Se for isso й sу o colocar DarArmas(playerid) dentro do OnPlayerConnect tambйm, e pronto ele vai spawnar com as armas coerentes ao score dele...
Eu tinha pensado nisso tambйm, coloquei em OnPlayerConnect porem ainda deu a mesma coisa, ainda spawna as armas dos scores corresponderdes somente depois que morre pela primeira vez.
Reply
#4

O problema й sу sintaxe.
Ao invйs de usar if, use switch:
Код:
DarArmas(playerid) 
{ 
    if(IsPlayerConnected(playerid)) 
    { 
		new score = GetPlayerScore(playerid);
        switch(score){ 

        	case 0 .. 30:{

            	GivePlayerWeapon(playerid, 24, 500);
       		}
       		
       		case 31 .. 80:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
			} 
        	
        	case 81 .. 150:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
        	} 
            
            case 151 .. 230:{

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 

        	} 
           
            case 231 .. 320:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 30, 1500); 
	            SetPlayerArmour(playerid, 20); 
        	}

	        case 321 .. 450:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 20);
	        }

            case 451 .. 700:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 27, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 20);
	        }

            case 701 .. 1000:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 27, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 60);
	        } 
           
            case 1001 .. 1337:{ // Gostei da referкncia

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 27, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 34, 90); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 60);
        	}

           	case 1337 .. 9999999:{

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 27, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 34, 90); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 100); 
	            GivePlayerWeapon(playerid, 37, 5); 
    		}
    	} 
    }
    
    return 1; 
}
Obs: Nгo compilei, mas deve estar tudo certo.
Obs2: Ctrl C, Ctrl V aqui no fуrum faz a identaзгo ficar louca. Quando for migrar para o seu cуdigo, arrume os erros, por favor
Reply
#5

Quote:
Originally Posted by Ermanhaut
Посмотреть сообщение
O problema й sу sintaxe.
Ao invйs de usar if, use switch:
Код:
DarArmas(playerid) 
{ 
    if(IsPlayerConnected(playerid)) 
    { 
		new score = GetPlayerScore(playerid);
        switch(score){ 

        	case 0 .. 30:{

            	GivePlayerWeapon(playerid, 24, 500);
       		}
       		
       		case 31 .. 80:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
			} 
        	
        	case 81 .. 150:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
        	} 
            
            case 151 .. 230:{

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 

        	} 
           
            case 231 .. 320:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 30, 1500); 
	            SetPlayerArmour(playerid, 20); 
        	}

	        case 321 .. 450:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 25, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 20);
	        }

            case 451 .. 700:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 27, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 20);
	        }

            case 701 .. 1000:{ 

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 27, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 60);
	        } 
           
            case 1001 .. 1337:{ // Gostei da referкncia

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 27, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 34, 90); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 60);
        	}

           	case 1337 .. 9999999:{

	            GivePlayerWeapon(playerid, 24, 500); 
	            GivePlayerWeapon(playerid, 27, 500); 
	            GivePlayerWeapon(playerid, 29, 500); 
	            GivePlayerWeapon(playerid, 34, 90); 
	            GivePlayerWeapon(playerid, 31, 1500); 
	            SetPlayerArmour(playerid, 100); 
	            GivePlayerWeapon(playerid, 37, 5); 
    		}
    	} 
    }
    
    return 1; 
}
Obs: Nгo compilei, mas deve estar tudo certo.
Obs2: Ctrl C, Ctrl V aqui no fуrum faz a identaзгo ficar louca. Quando for migrar para o seu cуdigo, arrume os erros, por favor
Tentei aqui, mas nгo compila fica nгo apresenta erro nem nada, apenas fica a vida toda compliando, e nunca compila, obs: nгo dei Ctrl c, Ctrl v :V
Reply
#6

Posta o cуdigo, deve estar faltando algum }
Reply
#7

Quote:
Originally Posted by Ermanhaut
Посмотреть сообщение
Posta o cуdigo, deve estar faltando algum }
Pelo que eu vi, o que n ta deixando compilar й exatamente nessa parte

PHP код:
             case 1337 .. 9999999:{ 
Se eu coloco mais de 5 nъmero "99999" a cima para de compilar
Reply
#8

Deve ter um limite mesmo... faзa assim entгo:
Код:
// Depois de case 1001 .. 1337
default:{ // isto quer dizer que se nenhuma das alternativas acima estiver correta, execute isto
  GivePlayerWeapon(playerid, 24, 500);  
  GivePlayerWeapon(playerid, 27, 500); 
  GivePlayerWeapon(playerid, 29, 500); 
  GivePlayerWeapon(playerid, 34, 90); 
  GivePlayerWeapon(playerid, 31, 1500); 
  SetPlayerArmour(playerid, 100); 
  GivePlayerWeapon(playerid, 37, 5);
}
Reply
#9

Quote:
Originally Posted by Ermanhaut
Посмотреть сообщение
.
Ficou assim, compila normal e tals, como antes, mas ainda esse mesmo bug, as armas de score mais alto so spawnada depois que o player more


PHP код:
DarArmas(playerid

    if(
IsPlayerConnected(playerid)) 
    { 
        new 
score GetPlayerScore(playerid); //
        
switch(score){ 
            case 
.. 30:{
                
GivePlayerWeapon(playerid24500);
               }
               
               case 
31 .. 80:{ 
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid25500); 
            } 
            
            case 
81 .. 150:{ 
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid25500); 
                
GivePlayerWeapon(playerid29500); 
            } 
            
            case 
151 .. 230:{
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid25500); 
                
GivePlayerWeapon(playerid29500); 
            } 
           
            case 
231 .. 320:{ 
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid25500); 
                
GivePlayerWeapon(playerid29500); 
                
GivePlayerWeapon(playerid301500); 
                
SetPlayerArmour(playerid20); 
            }
            case 
321 .. 450:{ 
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid25500); 
                
GivePlayerWeapon(playerid29500); 
                
GivePlayerWeapon(playerid311500); 
                
SetPlayerArmour(playerid20);
            }
            case 
451 .. 700:{ 
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid27500); 
                
GivePlayerWeapon(playerid29500); 
                
GivePlayerWeapon(playerid311500); 
                
SetPlayerArmour(playerid20);
            }
            case 
701 .. 1000:{ 
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid27500); 
                
GivePlayerWeapon(playerid29500); 
                
GivePlayerWeapon(playerid311500); 
                
SetPlayerArmour(playerid60);
            } 
           
            case 
1001 .. 1337:{ // Gostei da referкncia
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid27500); 
                
GivePlayerWeapon(playerid29500); 
                
GivePlayerWeapon(playerid3490); 
                
GivePlayerWeapon(playerid311500); 
                
SetPlayerArmour(playerid60);
            }
               case 
1338 .. 9999:{
                
GivePlayerWeapon(playerid24500); 
                
GivePlayerWeapon(playerid27500); 
                
GivePlayerWeapon(playerid29500); 
                
GivePlayerWeapon(playerid3490); 
                
GivePlayerWeapon(playerid311500); 
                
SetPlayerArmour(playerid100); 
                
GivePlayerWeapon(playerid375); 
            }
            default:
            {
                  
GivePlayerWeapon(playerid24500);  
                  
GivePlayerWeapon(playerid27500); 
                  
GivePlayerWeapon(playerid29500); 
                  
GivePlayerWeapon(playerid3490); 
                  
GivePlayerWeapon(playerid311500); 
                  
SetPlayerArmour(playerid100); 
                  
GivePlayerWeapon(playerid375);
            }
        }
    }
    return 
1;

Reply
#10

Deve estar dando algum problema com a callback OnPlayerSpawn, ela costuma ser um pouco bugada. Tente isto:
Код:
forward DarArmas(playerid); public DarArmas(playerid){
  //  Cole o cуdigo aqui
}

public OnPlayerSpawn(playerid){
  SetTimerEx("DarArmas", 500, false, "d", playerid);
  return 1;
}
Obs: Eu fiz o cуdigo aqui no meu GM e funcionou. Se nгo funciona no seu й porque vocк deve ter alguma coisa bloqueando o cуdigo de ser executado.
Tem mais alguma coisa em OnPlayerSpawn()?

Meu cуdigo:

Код:
public OnPlayerSpawn(playerid) {
  GivePlayerWeapons(playerid);
  return 1;
}

stock GivePlayerWeapons(playerid) {

  new score = GetPlayerScore(playerid);
  switch(score){  

    case 0 .. 30: { 

      GivePlayerWeapon(playerid, 24, 500); 
    } 
        
    case 31 .. 80: {  

      GivePlayerWeapon(playerid, 24, 500);  
      GivePlayerWeapon(playerid, 25, 500);  
    }  
     
    case 81 .. 150: {  

      GivePlayerWeapon(playerid, 24, 500);  
      GivePlayerWeapon(playerid, 25, 500);  
      GivePlayerWeapon(playerid, 29, 500);  
    }  
     
    case 151 .. 230: { 

      GivePlayerWeapon(playerid, 24, 500);  
      GivePlayerWeapon(playerid, 25, 500);  
      GivePlayerWeapon(playerid, 29, 500);  

    }  
    
    case 231 .. 320: {  

      GivePlayerWeapon(playerid, 24, 500);  
      GivePlayerWeapon(playerid, 25, 500);  
      GivePlayerWeapon(playerid, 29, 500);  
      GivePlayerWeapon(playerid, 30, 1500);  
      SetPlayerArmour(playerid, 20);  
    } 

    case 321 .. 450: {  

      GivePlayerWeapon(playerid, 24, 500);  
      GivePlayerWeapon(playerid, 25, 500);  
      GivePlayerWeapon(playerid, 29, 500);  
      GivePlayerWeapon(playerid, 31, 1500);  
      SetPlayerArmour(playerid, 20); 
    } 

    case 451 .. 700: {  

      GivePlayerWeapon(playerid, 24, 500);  
      GivePlayerWeapon(playerid, 27, 500);  
      GivePlayerWeapon(playerid, 29, 500);  
      GivePlayerWeapon(playerid, 31, 1500);  
      SetPlayerArmour(playerid, 20); 
    } 

    case 701 .. 1000: {  

      GivePlayerWeapon(playerid, 24, 500);  
      GivePlayerWeapon(playerid, 27, 500);  
      GivePlayerWeapon(playerid, 29, 500);  
      GivePlayerWeapon(playerid, 31, 1500);  
      SetPlayerArmour(playerid, 60); 
    }  
    
    case 1001 .. 1337: {

      GivePlayerWeapon(playerid, 24, 500);  
      GivePlayerWeapon(playerid, 27, 500);  
      GivePlayerWeapon(playerid, 29, 500);  
      GivePlayerWeapon(playerid, 34, 90);  
      GivePlayerWeapon(playerid, 31, 1500);  
      SetPlayerArmour(playerid, 60); 
    }

    default: { 
      GivePlayerWeapon(playerid, 24, 500);   
      GivePlayerWeapon(playerid, 27, 500);  
      GivePlayerWeapon(playerid, 29, 500);  
      GivePlayerWeapon(playerid, 34, 90);  
      GivePlayerWeapon(playerid, 31, 1500);  
      SetPlayerArmour(playerid, 100);  
      GivePlayerWeapon(playerid, 37, 5); 
    } 
  }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)