SSGamers - 12 Anos online por você.

#SSGamers - A Comunidade que mais crescer no brasil!

Participe do fórum, é rápido e fácil

SSGamers - 12 Anos online por você.

#SSGamers - A Comunidade que mais crescer no brasil!

SSGamers - 12 Anos online por você.

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.
Chegou o novo tema 6.5.5 - SSGamers - Servidores online de qualidade - Aproveite e entre para nossa comunidade, inscreva-se já! - Ouça nossa web radio - Veja nossas novidades - Participe dos nossos setores de jogos online - Parcerias aberta fale já com um administrador.

3 participantes

    Códigos Úteis #1 - JFS

    Weslley_Script
    Weslley_Script
    SS - Fundador
    SS - Fundador


    Steam Steam : WeslleySSGames
    Zello : WeslleySSGames
    Mensagens : 11351
    Moedas : 1031858
    Data de inscrição : 06/10/2011
    Idade : 28
    Localização : Brasil

    Códigos Úteis #1 - JFS Empty Códigos Úteis #1 - JFS

    Mensagem por Weslley_Script Qui 18 Abr 2019 - 9:38

    WHILE



    Código:
    new j; 
    while (j < 10000000) 

            ++j; 
    }  

    FOR



    Código:
    new f; 
    for( ; f < 10000000 ; ++f) 


    }  

    GOTO



    Código:
    new s = 10000000; 

    loop: 
    if(--s) 

        goto loop; 
    }  

    RESPOSTAS

    Code:

    Código:
    WHILE - Tempo: 146
    FOR - Tempo: 125
    GOTO - Tempo: 197


    For usado igual While é mais rápido. Goto é lento, porém nesse estilo decrescente, ele é 20% mais rápido.

    Uma simples contagem chata de 'exercícios' de cursos rs
    Código:
    for(x = 1, y = 10; x <= 10; ++x, --y) 

        printf("%d %d", y, x); 


    /* 
    10 1 
    9 2 
    8 3 
    7 4 
    6 5 
    5 6 
    4 7 
    3 8 
    2 9 
    1 10 
    */  



    Códigos Úteis #1 - JFS D07Xwqb
    Códigos Úteis #1 - JFS Yjab9HN
    Chainksain
    Chainksain
    --> Postador Iniciante
    --> Postador Iniciante


    Mensagens : 13
    Moedas : 4374
    Data de inscrição : 04/05/2012

    Códigos Úteis #1 - JFS Empty Re: Códigos Úteis #1 - JFS

    Mensagem por Chainksain Seg 2 Set 2019 - 14:18

    isso não é código e mt menos útil... vou deixar uns códigos uteis de verdade aqui:


    Código:
    stock GetPlayerNameEx(playerid)
    {
        new pNome[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pNome, sizeof(pNome));
        return pNome;
    }



    Código:
    stock IsPlayerInRangeOfPlayer(playerid, Float:range, giveplayerid)
    {
     new Float:x, Float:y, Float:z;
        GetPlayerPos(giveplayerid,x,y,z);
        if(IsPlayerInRangeOfPoint(playerid, range, x, y, z)) return true;
        else return false;
    }




    Código:
    stock SpawnVehicleInfrontOfPlayer(playerid, vehiclemodel, color1, color2)
    {
        new Float:x,Float:y,Float:z;
        new Float:facing;
        new Float:distance;

     GetPlayerPos(playerid, x, y, z);
     GetPlayerFacingAngle(playerid, facing);

     new Float:size_x,Float:size_y,Float:size_z;
        GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
       
        distance = size_x + 0.5;

       x += (distance * floatsin(-facing, degrees));
     y += (distance * floatcos(-facing, degrees));

        facing += 90.0;
        if(facing > 360.0) facing -= 360.0;

        return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
    }




    Código:
    stock CreateExplosionEx(Float:X, Float:Y, Float:Z, type, Float:Radius, virtualworld)
    {
        new x;
        while(x != MAX_PLAYERS) {
            if(IsPlayerConnected(x)) {
              if(virtualworld == -1 || virtualworld == GetPlayerVirtualWorld(x)) {
                    CreateExplosionForPlayer(x, X, Y, Z, type, Radius);
                }
            }
            x++;
        }
    }




    Código:
    stock isNumeric(const string[])
    {
      new length=strlen(string);
      if (length==0) return false;
      for (new i = 0; i < length; i++)
        {
          if (
                (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
                 || (string[i]=='-' && i!=0)                                             // A '-' but not at first.
                 || (string[i]=='+' && i!=0)                                             // A '+' but not at first.
             ) return false;
        }
      if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
      return true;
    }




    Código:
    stock PlaySoundForAll(soundid, Float:x, Float:y, Float:z)
    {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                PlayerPlaySound(i, soundid, x, y, z);
            }
        }
    }




    Código:
    stock PlaySoundForPlayersInRange(soundid, Float:range, Float:x, Float:y, Float:z)
    {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i,range,x,y,z))
            {
                PlayerPlaySound(i, soundid, x, y, z);
            }
        }
    }




    Código:
    stock IsKeyJustDown(key, newkeys, oldkeys)
    {
        if((newkeys & key) && !(oldkeys & key)) return 1;
        return 0;
    }




    Código:
    stock ReturnUser(const text[])
    {
        new pos = 0;
        new userid = RETURN_USER_FAILURE;
           
        while(text[pos] < 0x21) { // Strip out leading spaces
            if(text[pos] == 0) return RETURN_USER_FAILURE; // No passed text
            pos++;
        }
           
        if(isNumeric(text[pos])) { // Check whole passed string
            userid = strval(text[pos]);
            if(userid >=0 && userid < MAX_PLAYERS)
            {
                if(IsPlayerConnected(userid)) return userid;
                return RETURN_USER_FAILURE;
            }
        }
       
        // They entered [part of] a name or the id search failed (check names just incase)
        new len = strlen(text[pos]);
        new count = 0;
        new name[MAX_PLAYER_NAME+1];
       
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                GetPlayerName(i, name, sizeof(name));
                if(strcmp(name, text[pos], true, len) == 0) // Check segment of name
                {
                    if(len == strlen(name)) { // Exact match
                        return i;
                    }
                    else { // Partial match
                        count++;
                        userid = i;
                    }
                }
            }
        }
       
        if(!count) return RETURN_USER_FAILURE;
        if(count > 1) return RETURN_USER_MULTIPLE;
       
        return userid;
    }
    Weslley_Script
    Weslley_Script
    SS - Fundador
    SS - Fundador


    Steam Steam : WeslleySSGames
    Zello : WeslleySSGames
    Mensagens : 11351
    Moedas : 1031858
    Data de inscrição : 06/10/2011
    Idade : 28
    Localização : Brasil

    Códigos Úteis #1 - JFS Empty Re: Códigos Úteis #1 - JFS

    Mensagem por Weslley_Script Qui 12 Set 2019 - 13:14

    Chainksain escreveu:isso não é código e mt menos útil... vou deixar uns códigos uteis de verdade aqui:


    Código:
    stock GetPlayerNameEx(playerid)
    {
        new pNome[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pNome, sizeof(pNome));
        return pNome;
    }



    Código:
    stock IsPlayerInRangeOfPlayer(playerid, Float:range, giveplayerid)
    {
     new Float:x, Float:y, Float:z;
        GetPlayerPos(giveplayerid,x,y,z);
        if(IsPlayerInRangeOfPoint(playerid, range, x, y, z)) return true;
        else return false;
    }




    Código:
    stock SpawnVehicleInfrontOfPlayer(playerid, vehiclemodel, color1, color2)
    {
        new Float:x,Float:y,Float:z;
        new Float:facing;
        new Float:distance;

     GetPlayerPos(playerid, x, y, z);
     GetPlayerFacingAngle(playerid, facing);

     new Float:size_x,Float:size_y,Float:size_z;
        GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
       
        distance = size_x + 0.5;

       x += (distance * floatsin(-facing, degrees));
     y += (distance * floatcos(-facing, degrees));

        facing += 90.0;
        if(facing > 360.0) facing -= 360.0;

        return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
    }




    Código:
    stock CreateExplosionEx(Float:X, Float:Y, Float:Z, type, Float:Radius, virtualworld)
    {
        new x;
        while(x != MAX_PLAYERS) {
            if(IsPlayerConnected(x)) {
              if(virtualworld == -1 || virtualworld == GetPlayerVirtualWorld(x)) {
                    CreateExplosionForPlayer(x, X, Y, Z, type, Radius);
                }
            }
            x++;
        }
    }




    Código:
    stock isNumeric(const string[])
    {
      new length=strlen(string);
      if (length==0) return false;
      for (new i = 0; i < length; i++)
        {
          if (
                (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
                 || (string[i]=='-' && i!=0)                                             // A '-' but not at first.
                 || (string[i]=='+' && i!=0)                                             // A '+' but not at first.
             ) return false;
        }
      if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
      return true;
    }




    Código:
    stock PlaySoundForAll(soundid, Float:x, Float:y, Float:z)
    {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                PlayerPlaySound(i, soundid, x, y, z);
            }
        }
    }




    Código:
    stock PlaySoundForPlayersInRange(soundid, Float:range, Float:x, Float:y, Float:z)
    {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i,range,x,y,z))
            {
                PlayerPlaySound(i, soundid, x, y, z);
            }
        }
    }




    Código:
    stock IsKeyJustDown(key, newkeys, oldkeys)
    {
        if((newkeys & key) && !(oldkeys & key)) return 1;
        return 0;
    }




    Código:
    stock ReturnUser(const text[])
    {
        new pos = 0;
        new userid = RETURN_USER_FAILURE;
           
        while(text[pos] < 0x21) { // Strip out leading spaces
            if(text[pos] == 0) return RETURN_USER_FAILURE; // No passed text
            pos++;
        }
           
        if(isNumeric(text[pos])) { // Check whole passed string
            userid = strval(text[pos]);
            if(userid >=0 && userid < MAX_PLAYERS)
            {
                if(IsPlayerConnected(userid)) return userid;
                return RETURN_USER_FAILURE;
            }
        }
       
        // They entered [part of] a name or the id search failed (check names just incase)
        new len = strlen(text[pos]);
        new count = 0;
        new name[MAX_PLAYER_NAME+1];
       
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                GetPlayerName(i, name, sizeof(name));
                if(strcmp(name, text[pos], true, len) == 0) // Check segment of name
                {
                    if(len == strlen(name)) { // Exact match
                        return i;
                    }
                    else { // Partial match
                        count++;
                        userid = i;
                    }
                }
            }
        }
       
        if(!count) return RETURN_USER_FAILURE;
        if(count > 1) return RETURN_USER_MULTIPLE;
       
        return userid;
    }
    valeu!



    Códigos Úteis #1 - JFS D07Xwqb
    Códigos Úteis #1 - JFS Yjab9HN
    Stremmer_Scripter#0961
    Stremmer_Scripter#0961
    --> Postador Fanático
    --> Postador Fanático


    Celular : 17981120325
    Mensagens : 681
    Moedas : 2966
    Data de inscrição : 19/10/2019
    Idade : 28

    Códigos Úteis #1 - JFS Empty Re: Códigos Úteis #1 - JFS

    Mensagem por Stremmer_Scripter#0961 Dom 2 Jan 2022 - 19:56

    mando legal manolo

    Conteúdo patrocinado


    Códigos Úteis #1 - JFS Empty Re: Códigos Úteis #1 - JFS

    Mensagem por Conteúdo patrocinado


      Data/hora atual: Sex 29 Mar 2024 - 2:48