Cуdigos Ъteis #1

Quote:
Originally Posted by paulor
Посмотреть сообщение
Isso ae й um Loop vicioso em... Uma baita de uma redundвncia.
Eu apercebi-me disso...
Mas se eu fosse dizer-lhe isso, muita gente iria me contradiar.
Reply

pawn Код:
em C>> atan2(y,x)
em Pawn>> atan2(x,y)
Com base nisto, fiz uma funзгo para deixar igual a c.
pawn Код:
stock Float:latan(Float:y, Float:x)
{
  x = atan2(y, x) - 90.0;
  if(x < 0.0) return x + 90.0;
  else return x;
}

// teste do latan.
public OnFilterScriptInit()
{
    printf(#meu: %f --- outro: %f,latan(4.0,2.0),atan2(4.0,2.0));
}
Se tiver errads sу falar.
Reply

Quote:
Originally Posted by leonardo1434
Посмотреть сообщение
pawn Код:
em C>> atan2(y,x)
em Pawn>> atan2(x,y)
Com base nisto, fiz uma funзгo para deixar igual a c.
pawn Код:
stock Float:latan(Float:y, Float:x)
{
  x = atan2(y, x) - 90.0;
  if(x < 0.0) return x + 90.0;
  else return x;
}

// teste do latan.
public OnFilterScriptInit()
{
    printf(#meu: %f --- outro: %f,latan(4.0,2.0),atan2(4.0,2.0));
}
Se tiver errads sу falar.
Essa funзгo vai dar este warning:
"warning 208: function with tag result used before definition, forcing reparse"
Reply

Quote:
Originally Posted by leonardo1434
Посмотреть сообщение
pawn Код:
em C>> atan2(y,x)
em Pawn>> atan2(x,y)
Com base nisto, fiz uma funзгo para deixar igual a c.
pawn Код:
stock Float:latan(Float:y, Float:x)
{
  x = atan2(y, x) - 90.0;
  if(x < 0.0) return x + 90.0;
  else return x;
}

// teste do latan.
public OnFilterScriptInit()
{
    printf(#meu: %f --- outro: %f,latan(4.0,2.0),atan2(4.0,2.0));
}
Se tiver errads sу falar.
O atan2 de C retorna um вngulo em radianos e o de Pawn retorna um вngulo em graus .



Essa й a ъnica diferenзa entre essas funзхes.



Vocк deve ter se enganado devido ao modo como as includes do SA-MP declaram essa funзгo :


pawn Код:
native Float:atan2(Float:x, Float:y);

Sendo que na realidade, isto faria mais sentido:


pawn Код:
native Float:atan2(Float:y, Float:x);

A partir disso, conclui-se que foi um erro do autor das includes .



Ele provavelmente se confundiu com o par ordenado de representaзгo de coordenadas de um ponto no plano cartesiano: (x, y).



Para consertar sua funзгo, resolva a seguinte regra de trкs :





Considere a como o retorno do atan2 de Pawn e b como o do de C .



Quote:
Originally Posted by ipsBruno
Посмотреть сообщение
Firecat, funзхes com retorno assim devem ser colocadas na parte de cima do cуdigo, na parte de baixo dб este erro.
Isso ou deixar a definiзгo da funзгo abaixo do local de sua chamada e seu protуtipo acima :


pawn Код:
#include <a_samp>


forward Float:Funcao();


main()
{
    printf("%f", Funcao());
}


stock Float:Funcao()
{
    new Float:Var = floatsin(30, degrees);
    return Var;
}

Essa dica й ъtil para alguns tipos de organizaзгo de GM.




OMaior



Esse cуdigo retorna uma array contendo o maior valor que hб em determinada variбvel array e o нndice da parte dela na qual estб armazenado .



Crйditos: rjjj ou Ken pela feitura dos cуdigos.



Aqui estб :


pawn Код:
stock OMaior(array[], tamanho = sizeof(array))
{
    new Elemento, Ultimo, Valor, Indice;
    for(new x = 0; x < tamanho; x++)
    {
        Elemento = array[x];
        if(Elemento > Ultimo)
        {
            Valor = Elemento;
            Indice = x;
        }
        Ultimo = Elemento;
    }
    new Final[2];
    Final[0] = Valor;
    Final[1] = Indice;
    return Final;
}


Exemplo de uso:


pawn Код:
new Var[2];
new Lista[] = {2, 5, 1, 10, 3};
Var = OMaior(Lista);
printf("[O Maior] Valor: %d.  Нndice: %d.", Var[0], Var[1]); //Mostraria o nъmero 10 (maior valor da array Lista) e o nъmero 3 (нndice da parte da array Lista que contйm o maior valor).



Espero ter ajudado .
Reply

Quote:
Originally Posted by ipsBruno
Посмотреть сообщение
Ah Te Amooooooo,,,


Enviar Mensagem ao Player
pawn Код:
if(strcmp(cmd, "/ambrosio", true) == 0) //-- Comando
    {
        SendClientMessage(playerid,COR,"MENSAGEM "); //MSG
        SendClientMessage(playerid,COR,"MELHOR TOPICO EU AMO O AMBROSIO rs"); //MSG
        return 1;
    }
Animaзхes
pawn Код:
//---------------------ANIMAЗХES---------------------------------------------
if(strcmp("/renderse", cmd, true) == 0)
{
SetPlayerSpecialAction(playerid, 10);
return 1;
}
if(strcmp("/ligar", cmd, true) == 0)
{
SetPlayerSpecialAction(playerid, 11);
return 1;
}
if(strcmp("/desligar", cmd, true) == 0)
{
SetPlayerSpecialAction(playerid, 13);
return 1;
}
if(strcmp("/bebado", cmd, true) == 0)
{
ApplyAnimation(playerid, "PED", "WALK_DRUNK", 4.0, 1, 1, 1, 1, 0);
return 1;
}
if(strcmp("/bomba", cmd, true) == 0)
{
ClearAnimations(playerid);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/apontar", cmd, true) == 0)
{
ApplyAnimation(playerid, "ped", "ARRESTgun", 4.0, 0, 1, 1, 1, -1);
return 1;
}
if(strcmp("/merda", cmd, true) == 0)
{
ApplyAnimation(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/mascararse", cmd, true) == 0)
{
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 4.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/roubar", cmd, true) == 0)
{
ApplyAnimation(playerid, "SHOP", "ROB_Loop_Threat", 4.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/cruzarb", cmd, true) == 0)
{
ApplyAnimation(playerid, "COP_AMBIENT", "Coplook_loop", 4.0, 0, 1, 1, 1, -1);
return 1;
}
if(strcmp("/deitar", cmd, true) == 0)
{
ApplyAnimation(playerid, "BEACH", "bather", 4.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/abaixar", cmd, true) == 0)
{
ApplyAnimation(playerid, "ped", "cower", 3.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/vomitar", cmd, true) == 0)
{
ApplyAnimation(playerid, "FOOD", "EAT_Vomit_P", 3.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/comer", cmd, true) == 0)
{
ApplyAnimation(playerid, "FOOD", "EAT_Burger", 3.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/rap", cmd, true) == 0)
{
ApplyAnimation(playerid, "ON_LOOKERS", "wave_loop", 4.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/passaramao", cmd, true) == 0)
{
ApplyAnimation(playerid, "SWEET", "sweet_ass_slap", 4.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/cobrar", cmd, true) == 0)
{
ApplyAnimation(playerid, "DEALER", "DEALER_DEAL", 4.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/overdose", cmd, true) == 0)
{
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/fumar", cmd, true) == 0)
{
ApplyAnimation(playerid, "SMOKING", "M_smklean_loop", 4.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/fumar2", cmd, true) == 0)
{
ApplyAnimation(playerid, "SMOKING", "F_smklean_loop", 4.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/sentar", cmd, true) == 0)
{
ApplyAnimation(playerid, "BEACH", "ParkSit_M_loop", 4.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/conversar", cmd, true) == 0)
{
ApplyAnimation(playerid, "PED", "IDLE_CHAT", 4.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/fodase", cmd, true) == 0)
{
ApplyAnimation(playerid, "PED", "fucku", 4.0, 0, 0, 0, 0, 0);
return 1;
}
if(strcmp("/taichi", cmd, true) == 0)
{
ApplyAnimation(playerid, "PARK", "Tai_Chi_Loop", 4.0, 1, 0, 0, 0, 0);
return 1;
}
if(strcmp("/observar", cmd, true) == 0)
{
ApplyAnimation(playerid, "BAR", "dnk_stndF_loop", 4.0, 1, 0, 0, 0, 0);
return 1;
}
//---------------------Lista Animaзхes------------------------------------
if(strcmp("/animes", cmd, true) == 0)
{
SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "[DraKoN's Server]:Lista de Animes :");
SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "/renderse /ligar /desligar /bebado /bomba /apontar /merda /mascararse");
SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "/roubar /cruzarb /deitar /abaixar /vomitar /comer /rap /passaramao");
SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "/cobrar /overdose /fumar /fumar2 /sentar /conversar /fodase /taichi");
SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "/observar ");
return 1;
}
Suicidio
pawn Код:
if(strcmp("/kill", cmd, true) == 0)
{
SetPlayerHealth(playerid, 0);
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Voce Se Matou!");
return 1;
}
Reparar Carro
pawn Код:
//-------------------------------------------------------------------------
if(strcmp("/reparar", cmd, true) == 0)
{
SetVehicleHealth(playerid,100);
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Carro Reparado");
return 1;
}
//-------------------------------------------------------------------------
Nick Off
pawn Код:
if (strcmp("/nickoff", cmd, true) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, false);
GameTextForPlayer(playerid, "~W~Nicks Desativos ~R~off", 5000, 5);
return 1;
}
Nick ON
pawn Код:
if (strcmp("/nickon", cmd, true) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, true);
GameTextForPlayer(playerid, "~W~Nicks Ativos ~R~", 5000, 5);
return 1;
}
Comando Procurar Bots
pawn Код:
if(strcmp(cmd, "/bots", true) == 0)
{
SendClientMessage(playerid,AMARELO,"[DrK] Procurando Bots...");

for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
if(strcmp(ip, "255.255.255.255") == 0)
{
format(string,256,"[DrK] Bot Detectado! IP: %d",ip);
SendClientMessageToAll(LARANJA,string);
Kick(playerid);
return 0;
}
}
}
return 1;
}
Defines Algumas Cores
pawn Код:
//*********************Cores****************************************************
#define LARANJA     0xFF8C00AA
#define VERDE      0x33AA33AA
#define AMARELO     0xFFFF00AA
#define COLOR      0xFF0000AA
#define AZUL      0x33CCFFAA
#define AAZUL      0x2641FEAA
Level de Procurado + Score ao Matar

pawn Код:
//******************************************************************************
public OnPlayerDeath(playerid, killerid, reason)
{
    SetPlayerWantedLevel(killerid, 1);
    SetPlayerWantedLevel(playerid, 0);
    SetPlayerScore(killerid, GetPlayerScore(playerid) + 1);
    SetPlayerScore(playerid, GetPlayerScore(playerid) - 1);
    SendClientMessage(playerid,LARANJA,"Vocк morreu, perdeu 1 de Score, Digite /top.");
    SendClientMessage(killerid, AZUL, "Vocк matou e ganho 1 de Score, Digite /top.");
}


//******************************************************************************
Admins Onlines
pawn Код:
//-----------------------------Admins Online--------------------------
if(strcmp(cmdtext, "/admins", true) == 0){
new Jogador[24];
new count = 0;
new msg[120];
new ListaAdmins[128];
for(new i=0; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(i) && IsPlayerAdmin(i)){
GetPlayerName(i,Jogador,24);
format(msg,sizeof(msg),"Admins Online's: %s", Jogador);
SendClientMessage(playerid, 0x000FFFAA, msg);
count++;
}
}
if(count >= 0){
SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "Admins Off");
dini_IntSet (ListaAdmins, "Admins", 1);
SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, ListaAdmins);
}
return 1;
}

//------------------------------------------------------------------------------
/Favela: ir a favela

pawn Код:
//-------------------------------------------------------------------------
if(strcmp("/favelatraficante", cmd, true) == 0)
{
SendClientMessage(playerid,PM_OUTGOING_COLOR ,"/favelatraficante: para entrar ao trafico");
SendClientMessage(playerid,PM_OUTGOING_COLOR ,"/favelapolicial: para entra na policia");
return 1;
}
if(strcmp("/favelatraficante", cmd, true) == 0)
{
SendClientMessage(playerid,PM_OUTGOING_COLOR ,"Bem Vindo a Favela");
SetPlayerPos(playerid,2237.6868,-1079.4060,41.6102);
SetPlayerSkin(playerid, 268);
ResetPlayerWeapons(0);
GivePlayerWeapon(playerid, 26, 9999);
GivePlayerWeapon(playerid, 24, 9999);
GivePlayerWeapon(playerid, 31, 9999);
GivePlayerWeapon(playerid, 32, 9999);
return 1;
}
//-------------------------------------------------------------------------
if(strcmp("/favelapolicial", cmd, true) == 0)
{
SendClientMessage(playerid,PM_OUTGOING_COLOR ,"Bem Vindo a Favela");
SetPlayerPos(playerid,2237.6868,-1079.4060,41.6102);
SetPlayerSkin(playerid, 281);
ResetPlayerWeapons(0);
GivePlayerWeapon(playerid, 26, 9999);
GivePlayerWeapon(playerid, 24, 9999);
GivePlayerWeapon(playerid, 31, 9999);
GivePlayerWeapon(playerid, 32, 9999);
return 1;
}
Comando Idiota
pawn Код:
if (strcmp("/comando", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, 0xFF6347AA, "Eu Tambйm Sei Criar Comandos Idiotas");
GivePlayerMoney(playerid, 1);
return 1;
}
My Userbars
apenas um aviso no seu comando de reparar o carro ^.^ os veiculos pra fica com 100 de vida tem q bota 1000 kkk se vc bota 100 vc vai ta dando 10 de vida pro carro,ai...fufu xD
Reply

Quote:
Originally Posted by Sonik_Paintballer
Посмотреть сообщение
apenas um aviso no seu comando de reparar o carro ^.^ os veiculos pra fica com 100 de vida tem q bota 1000 kkk se vc bota 100 vc vai ta dando 10 de vida pro carro,ai...fufu xD
Se botar 100 vai ficar 10? Foda-se



Quote:

Garfiel nгo recomendo ninguйm a usar isto. imagina isso pra pegar uma string completa.

sscanf farб dezenas de comparaзхes na entrada "strng" que realmente serб mais lenta que o "getParam" do Garfield. Recomendo usar isto.


Mas enfim, o cуdigo pode ser muito melhorado de qualquer maneira


PHP код:

new ateCaractere[] = "," // usando virgulas 
new strng[] = "bla,ble,bli,blo,blu";  // string que vamos retirar 
new ateNumero 2    ;  // pegar apуs 0,1,2 virgulas. Ou seja "BLO" 
new string[0xff];  // string para colocar a parte retirada
static i;  // variбvel para fazer loop com strfind
while  (  (strfindstrngateCaracteretrue, ( ) ) ) != -) {  // ir procurando por "," virgulas
    
if( ! ateNumero  ) {  // caso as virgulas que deveriam ser achadas, chegarem a "zero". Achou as virgulas que deveria, entгo vamos cortar a strng
        
ateNumero   strfindstrngateCaracteretrue, ( ));  // pega a prуxima virgula para cortar
        
if(  ateNumero    == -1) {  // caso nгo achou uma prуxima virgula
            
ateNumero    strlen(strng);  // colocar o ponteiro para o final da strng
                        // isso ocorre por exemplo se fosse: "bla,ble,bli,blo" daн nгo teria virgula apуs o "blo"
        

        
strmid(stringstrng, (1), ateNumero); // cortar a strng da primeira virgula atй a ultima e passar para a nova "string"  
    

    
ateNumero  -- ;      // quando encontra uma, diminui o nъmero de virgulas para achar

print(string); 
// "BLO" 
Veja a lуgica, sу criar uma funзгo agora

Funciona, e й bem otimizado. Sу faz ago


Reply

Quote:
Originally Posted by ipsBruno
Посмотреть сообщение
Se botar 100 vai ficar 10? Foda-se





sscanf farб dezenas de comparaзхes na entrada "strng" que realmente serб mais lenta que o "getParam" do Garfield. Recomendo usar isto.


Mas enfim, o cуdigo pode ser muito melhorado de qualquer maneira


PHP код:

new ateCaractere[] = "," // usando virgulas 
new strng[] = "bla,ble,bli,blo,blu";  // string que vamos retirar 
new ateNumero 2    ;  // pegar apуs 0,1,2 virgulas. Ou seja "BLO" 
new string[0xff];  // string para colocar a parte retirada
static i;  // variбvel para fazer loop com strfind
while  (  (strfindstrngateCaracteretrue, ( ) ) ) != -) {  // ir procurando por "," virgulas
    
if( ! ateNumero  ) {  // caso as virgulas que deveriam ser achadas, chegarem a "zero". Achou as virgulas que deveria, entгo vamos cortar a strng
        
ateNumero   strfindstrngateCaracteretrue, ( ));  // pega a prуxima virgula para cortar
        
if(  ateNumero    == -1) {  // caso nгo achou uma prуxima virgula
            
ateNumero    strlen(strng);  // colocar o ponteiro para o final da strng
                        // isso ocorre por exemplo se fosse: "bla,ble,bli,blo" daн nгo teria virgula apуs o "blo"
        

        
strmid(stringstrng, (1), ateNumero); // cortar a strng da primeira virgula atй a ultima e passar para a nova "string"  
    

    
ateNumero  -- ;      // quando encontra uma, diminui o nъmero de virgulas para achar

print(string); 
// "BLO" 
Veja a lуgica, sу criar uma funзгo agora

Funciona, e й bem otimizado. Sу faz ago


Estou editando minha funзгo, depois eu atualizo

Pegar informaзхes do servidor via php
PHP код:
<?php
    $HostName     
"";
    
$GameMode    "";
    
$Map        "";
    
$Ping        "";
    
$PlayersOn    "";
    
$MaxPlayers "";
    
$Senha        0;
    
    
$IP_Servidor     "64.251.25.191";
    
$Porta_Servidor "26000";
    
    
$fp fsockopen('udp://' $IP_Servidor$Porta_Servidor$errno$errstr,0.0);
    if (!
$fp)
    {
        echo 
" offline";
    }
    else
    {
        
$packet 'SAMP';
        
$packet .= chr(strtok($IP_Servidor'.'));
        
$packet .= chr(strtok('.'));
        
$packet .= chr(strtok('.'));
        
$packet .= chr(strtok('.'));
        
$packet .= chr($Porta_Servidor 0xFF);
        
$packet .= chr($Porta_Servidor >> 0xFF);
        
fwrite($fp$packet.'i');
        
fread($fp11);
        
$Senha          ord(fread($fp1));
        
$PlayersOn      ord(fread($fp2));
        
$MaxPlayers     ord(fread($fp2));
        
$strlen         ord(fread($fp4));
        
$HostName       htmlentities(fread($fp$strlen));
        
$strlen         ord(fread($fp4));
        
$GameMode       htmlentities(fread($fp$strlen));
        
$strlen         ord(fread($fp4));
        
$Map            htmlentities(fread($fp$strlen));
        
$Ping             GetPing($IP_Servidor);//exec("ping ping -n 3 -l 64 $IP_Servidor ");
    
        
fwrite($fp$packet.'c');
        
fread($fp11);
        
fclose($fp);
    }
    
    function 
GetPing($ip=NULL
    {
        if(
getenv("OS")=="Windows_NT") {
        
$exec exec("ping -n 3 -l 64 ".$ip);
        return 
end(explode(" "$exec ));
    }
    else 
    {
        
$exec exec("ping -c 3 -s 64 -t 64 ".$ip);
        
$array explode("/"end(explode("="$exec )) );
        return 
ceil($array[1]) . 'ms';
    }
    
    
    
$Show "";
    
    
$Show .=    "<table><tr>";
    
$Show .=    "<tr><td><b>HostName:<b> </td> <td>".$HostName."</td></tr>";
    
$Show .=    "<tr><td><b>GameMode:<b> </td> <td>".$GameMode."</td></tr>";
    
$Show .=    "<tr><td><b>Map:<b> </td> <td>".$Map."</td></tr>";
    
$Show .=    "<tr><td><b>Ping:<b> </td> <td>".$Ping."</td></tr>";
    
$Show .=    "<tr><td><b>Players:<b> </td> <td>".$PlayersOn."/".$MaxPlayers."</td></tr>";
    
$Show .=    "<tr><td><b>Senha: <b></td> <td>".($Senha ? ("Sim") : ("Nгo"))."</td></tr>";
    
$Show .=    "</table>";
    
    echo 
$Show;
}
?>
Sу mude estas duas linhas:
PHP код:
$IP_Servidor     "64.251.25.191";
    
$Porta_Servidor "26000"
Reply

Quote:
Originally Posted by jQuery
View Post
Sei disso, й tipo um include do Js mas onde eu disse que й uma linguagem ? nгo me lembro agora kkkkk
Em sua assinatura amigo:
- "Iniciante em Pawn & jQuery"

Dб hб entender que jкquerн й uma linguagem de programaзгo..
Tem pessoas que nгo sabem que jQuery nada mais й que uma biblioteca
de funзхes criada por empresa nгo-oficial.

Um simples exemplo:
Code:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.js" ></script>
<script>
$().ready(function(){
        $('x').click(function(){
                $('texto'). slideDown();
        });
        $('o').click(function(){
                $('texto'). hide('slow', function(){
                });
               
        });
       
});
</script>
HTML Code:
<x><a href='#' >Aparecer</A></x>
<o><a href='#' >Desaparecer</a></o> <br />
<texto> Forum SA-MP</texto>
Reply

Aaa sim, mais a minha intenзгo nгo foi essa kkkk, minha intenзгo foi dizer que estou aprender Pawn e jQuery.
Reply

eu entendir normalmente ^^

Iniciante em: Direзгo e Matemбtica.

o "e" pode significar mts coisas, estude mais portuguкs =)
Reply

Quote:
Originally Posted by jpeg
View Post
eu entendir normalmente ^^

Iniciante em: Direзгo e Matemбtica.

o "e" pode significar mts coisas, estude mais portuguкs =)
"ENTENDIR","MTS" tem certeza que escreve assim?

"e" nгo significa muitas coisas, significa sу uma palavra,
oque eu questionei foi o contexto usado na palavra jQuery.


Para nгo deixar este post invбlido:



PHP Code:
stock RemoveWeapon(p, ...)
{
        static
                
Weap[MAX_PLAYERS][13][2],
                
Interator,              nInterator
        
;
        for (
Interator 0Interator 13Interator++) GetPlayerWeaponData(pInteratorWeap[p][Interator][0], Weap[p][Interator][1]);
        
ResetPlayerWeapons(p);
        for(
Interator 0Interator 13Interator++) {
                for(
nInterator 0nInterator numargs(); nInterator++){
                    if(
Weap[p][Interator][0] != getarg(nInterator)){
                                
GivePlayerWeapon(pWeap[p][Interator][0], Weap[p][Interator][1]);
                            
printf("Arg: %d | Wep: %d"getarg(nInterator), Weap[p][Interator][0]);
                        }
                }
        }
        return 
true;

Remover vбrias armas do player ao mesmo tempo:
PHP Code:
RemoveWeapon(playerid36,37,38); 
Reply

no portuguкs correto nao, mas eu escrevo =)

vc entendeu. o q vem dps do "e" pode significar mts coisas.

pawn Code:
stock fcreate(filename[])
{
    if(fexist(filename))
    {
        return false;
    }
    new File:fhandle = fopen(filename,io_write);
    fclose(fhandle);
    return 1;
}
Reply

Quote:
Originally Posted by jpeg
View Post
no portuguкs correto nao, mas eu escrevo =)

vc entendeu. o q vem dps do "e" pode significar mts coisas.

pawn Code:
stock fcreate(filename[])
{
    if(fexist(filename))
    {
        return false;
    }
    new File:fhandle = fopen(filename,io_write);
    fclose(fhandle);
    return 1;
}
PHP Code:
fcreate(filename[]) {
    return 
fexist(filename) ? false fclose(fopen(filenameio_write));

Reply

pawn Code:
#define fCreate(%0) fclose(fopen(%0, io_append))
Append > Se nгo existir cria, se existir, abre.
Reply

Quote:
Originally Posted by [Full]Garfield[XDB]
View Post
pawn Code:
#define fCreate(%0) fclose(fopen(%0, io_append))
Append > Se nгo existir cria, se existir, abre.
Boa, nгo tinha pensado nisso.
Reply

Mudar quantidade de dinheiro dos players selecionados

PHP Code:
stock setDefaultMoney money ,  ... ) {

    static
        
pInt
    
;
    
    
pInt numargs ( ) - 1;
    
    for ( ; ( 
pInt ) ; -- pInt ) {
    
        
ResetPlayerMoney getarg _: ( pInt ) ) ) ;
        
        
GivePlayerMoney getarg _: ( pInt ) ) , money ) ;
    }
    return 
true ;

Reply

O operador _: й usбvel apenas em valores flutuantes (floats). Ele converte o valor conforme as normas IEEE 754 com precisгo ъnica, tornando um valor inteiro. Pode usar em valores booleandos e outros tipos de tags, mas a funзгo й direcionada especificadamente para floats

Usar em valores inteiros em pawn й redundante

http://pt.wikipedia.org/wiki/Ponto_flutuante

Fica a dica para o pessoal

Permitindo armazenar o valor em variбveis comuns
PHP Code:
new Floatbla 10.5;
new 
blo _:(bla); // convertendo para os padrхes
print("%f em uma new nгo-float"Floatblo ); 
Abs
Reply

Quote:
Originally Posted by ipsBruno
View Post
O operador _: й usбvel apenas em valores flutuantes (floats). Ele converte o valor conforme as normas IEEE 754 com precisгo ъnica, tornando um valor inteiro. Pode usar em valores booleandos e outros tipos de tags, mas a funзгo й direcionada especificadamente para floats

Usar em valores inteiros em pawn й redundante

http://pt.wikipedia.org/wiki/Ponto_flutuante

Fica a dica para o pessoal

Permitindo armazenar o valor em variбveis comuns
PHP Code:
new Floatbla 10.5;
new 
blo _:(bla); // convertendo para os padrхes
print("%f em uma new nгo-float"Floatblo ); 
Abs
Nгo fale bosta. Vocк sу estб convertendo explicitamente o tipo da variavel. O valor continua no IEEE, mas representado em int. Para a conversгo completa, deve ser usada floatround(valor, floatround_round).
Reply

floatround serve para arredondar, arredondando vocк perde as casas decimais

10.5 -> 10

Ou vocк й burro e nгo entendeu o que eu falei, ou vocк й burro e nгo sabe o que estб falando.

#EDITADO

http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf

Pesquise por IEEE 754


Agora:
PHP Code:
    new amigo _:10.0505;
    
    
printf("%d"amigo); // 1092669145 
1092669145 й equivalente em 10.0505 em representaзгo IEEE 754. O nъmero й o mesmo, mas a representaзгo й diferente.

Usando floatround vocк obterб outra coisa


PHP Code:
    new amigo floatround(10.0505);
    
    
printf("%d"amigo); // 10 
Pois floatround nгo muda representaзгo nem nada, apenas "exclui" a parte decimal "arredondando" o nъmero



Explicado?

_____

Logo fazer

new olha = _:10;

Serб falho; primeiro que a conversгo de tags nгo ocorrerб porque o valor jб й propriamente o mesmo tipo que й declarado na variбvel; e segundo que a conversгo mesmo assim nгo funcionaria pois o nъmero jб й um inteiro com precisгo ъnica (IEEE nгo se encaixa na regra).
Reply

Postei na hora que o fуrum caiu.
Reply


Forum Jump:


Users browsing this thread: 48 Guest(s)