SA-MP Forums Archive
[Ajuda] Skills. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Skills. (/showthread.php?tid=644973)



Skills. - Hollyzinho - 17.11.2017

Se nгo me engano, cada arma tem suas Skills, exemplo: A m4 vocк pode andar atirando, mas em alguns servers, vocк sу tem como atirar parado com ela, como ativo pra ativar andando pros lados com ela? E como ativo somente para um player?


Re: Skills. - Marllun - 17.11.2017

Que eu me lembro a skill vem no mбximo.


Re: Skills. - C4rtm4n - 17.11.2017

Quote:
Originally Posted by Marllun
Посмотреть сообщение
Que eu me lembro a skill vem no mбximo.
Ela vem no mбximo mas pode re-configurar.

Quote:
Originally Posted by Hollyzinho
Посмотреть сообщение
Se nгo me engano, cada arma tem suas Skills, exemplo: A m4 vocк pode andar atirando, mas em alguns servers, vocк sу tem como atirar parado com ela, como ativo pra ativar andando pros lados com ela? E como ativo somente para um player?
Tem sу ler https://sampwiki.blast.hk/wiki/SetPlayerSkillLevel


Re: Skills. - Marllun - 17.11.2017

Obrigado cara, nгo sabia sobre isso entгo acabei de criar um comando pequeno de test.

link com id das armas:https://sampwiki.blast.hk/wiki/Weapons

lembrando algumas nгo tem skill

Mudar a skill de um player especifico
PHP код:

CMD
:mudarskill(playeridparams[])
{
    new 
id;
        new 
SS[80];
    new 
mudarskill;
    new 
armaid;
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
    if(
sscanf(params"udd",id,armaid,mudarskill)) return SendClientMessage(playerid,-1,"Use: /MudarSkill [Nome/ID] [Arma] [Quantidade]");
    if(
mudarskill 100 ||mudarskill 0) return SendClientMessage(playerid, -1,"Mбximo 100 minimo 0");
    
SetPlayerSkillLevel(idarmaidmudarskill);
    
format(SSsizeof(SS), "Vocк mudou a skill do %s para %d",name,mudarskill);
    
SendClientMessageToAll(0x4169E1,SS);
    return 
1;

Mudar a skill de todos de uma vez
PHP код:

CMD
:setarskilldetodos(playeridparams[])
{
    new 
mudarskill;
    new 
armaid;
        new 
SS[80];
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        
SetPlayerSkillLevel(iarmaidmudarskill);
    }
    if(
sscanf(params"udd",id,armaid,mudarskill)) return SendClientMessage(playerid,-1,"Use: /MudarSkill [Arma] [Quantidade]");
    if(
mudarskill 100 ||mudarskill 0) return SendClientMessage(playerid, -1,"Maximo 100 minimo 0");
    
format(SSsizeof(SS), "O administrador(a) %s mudou a skill de todos para %i ",name,mudarskill);
    
SendClientMessageToAll(-1,SS);
    return 
1;




Re: Skills. - Pool - 18.11.2017

Quote:
Originally Posted by Marllun
Посмотреть сообщение
Obrigado cara, nгo sabia sobre isso entгo acabei de criar um comando pequeno de test.

link com id das armas:https://sampwiki.blast.hk/wiki/Weapons

lembrando algumas nгo tem skill

Mudar a skill de um player especifico
PHP код:

CMD
:mudarskill(playeridparams[])
{
    new 
id;
        new 
SS[80];
    new 
mudarskill;
    new 
armaid;
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
    if(
sscanf(params"udd",id,armaid,mudarskill)) return SendClientMessage(playerid,-1,"Use: /MudarSkill [Nome/ID] [Arma] [Quantidade]");
    if(
mudarskill 100 ||mudarskill 0) return SendClientMessage(playerid, -1,"Mбximo 100 minimo 0");
    
SetPlayerSkillLevel(idarmaidmudarskill);
    
format(SSsizeof(SS), "Vocк mudou a skill do %s para %d",name,mudarskill);
    
SendClientMessageToAll(0x4169E1,SS);
    return 
1;

Mudar a skill de todos de uma vez
PHP код:

CMD
:setarskilldetodos(playeridparams[])
{
    new 
mudarskill;
    new 
armaid;
        new 
SS[80];
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        
SetPlayerSkillLevel(iarmaidmudarskill);
    }
    if(
sscanf(params"udd",id,armaid,mudarskill)) return SendClientMessage(playerid,-1,"Use: /MudarSkill [Arma] [Quantidade]");
    if(
mudarskill 100 ||mudarskill 0) return SendClientMessage(playerid, -1,"Maximo 100 minimo 0");
    
format(SSsizeof(SS), "O administrador(a) %s mudou a skill de todos para %i ",name,mudarskill);
    
SendClientMessageToAll(-1,SS);
    return 
1;

A sua funзгo estб errada, vou retratar de uma forma mais coerente e legнvel para o amigo...
Estude um pouco sobre a regra de nomenclatura das variбveis, encontrei um site que й bem resumido se tratando do mesmo. Entгo, aconselho dar uma olhadinha, a explicaзгo se passa em C, mas pawn й uma linguagem semelhante a C, e vocк pode se basear...
Link - NOMENCLATURA DE VARIБVEIS EM C

@Topic

A funзгo que vocк deseja, simplesmente se retrata em uma funзгo nativa jб existente dentro da linguagem,
a SetPlayerSkillLevel.

Agora irei citar um exemplo para vocк compreender um pouco melhor...

Primeiro de tudo, vamos entender a descriзгo da funзгo.:

"Set the skill level of a certain weapon type for a player."/"Defina o nнvel de habilidade de um certo tipo de arma para um jogador."

Ou seja, a funзгo irб definir o nнvel de habilidade de uma arma especнfica para o jogador.

Agora, vamos entender os parвmetros da funзгo. Por fim, a conclusгo dos parвmetros serб a seguinte:
PHP код:
SetPlayerSkillLevel(playeridskilllevel); 
Um exemplo, й o do prуprio Wiki-SAMP:
PHP код:
public OnPlayerSpawn(playerid)
{
    
SetPlayerSkillLevel(playeridWEAPONSKILL_SAWNOFF_SHOTGUN1);
    
// Isso farб com que o jogador utilize, duas espingardas, uma em cada mгo.
    
return 1;

Na callback, eu estou dando a funзгo de que, ao player spawnar, automaticamente ele serб setado com essa habilidade.

Agora, vamos para um exemplo um pouco mais "avanзado", nй?
Utilizando sscanf2 e pawn.cmd, vou desenvolver um simples comando para setar o skill de um jogador especнfico. Й semelhante ao do amigo acima, mas nгo igualado.
PHP код:
CMD:setskill(playeridparams[])
{
    new 
idid_weaponvalue_of_skill;
    if(!
sscanf(params"udd"idid_weaponvalue_of_skill))
    {
        if(
value_of_skill || value_of_skill 999)
            return 
SendClientMessage(playerid, -1"[AVISO] - A quantidade de nнvel, somente vбlida de 0 atй 999.");
        
SendClientMessage(playerid, -1"[AVISO] - Comando executado com sucesso!");
        
SetPlayerSkillLevel(idid_weaponvalue_of_skill);
    }
    else
        return 
SendClientMessage(playerid, -1"[AVISO] - A regra de utilizaзгo й: '/setskill' [ID do jogador] [ID da arma] [Quantidade de nнvel]");
    return 
true;

Primeiro, eu criei variбveis para armazenar os valores dos parвmetros, do qual, o mesmo serб decidido pelo autor da execuзгo do comando. (No caso, 'playerid'.)
Apуs, fiz uma condicional do sscanf utilizando o operador de negaзгo para retornar com uma mensagem ao final.
Abri brackets e por fim, executei todas as funзхes adicionais.

Ajudei? Retribua com uma reputaзгo!