Cуdigos Ъteis #1

pawn Код:
#define GetPlayerId() ((playerid))
isage:

pawn Код:
Kick(GetPlayerId());
Reply

pawn Код:
stock GivePlayerRandomWeapons(playerid)
{
  new Randomico = random(4);  
  if(Randomico == 1)
  {
     GivePlayerWeapon(playerid,24,350);
     GivePlayerWeapon(playerid,27,230);
     GivePlayerWeapon(playerid,31,530);
     GivePlayerWeapon(playerid,9,1);
  }
  if(Randomico == 2)
  {
     GivePlayerWeapon(playerid,24,350);
     GivePlayerWeapon(playerid,30,530);
     GivePlayerWeapon(playerid,25,200);
     GivePlayerWeapon(playerid,8,1);
  }
  if(Randomico == 3)
  {
     GivePlayerWeapon(playerid,24,350);
     GivePlayerWeapon(playerid,27,230);
     GivePlayerWeapon(playerid,31,530);
     GivePlayerWeapon(playerid,18,10);
  }
  if(Randomico == 4)
  {
     GivePlayerWeapon(playerid,24,350);
     GivePlayerWeapon(playerid,25,200);
     GivePlayerWeapon(playerid,29,530);
     GivePlayerWeapon(playerid,4,1);
  }
  return true;
}
Reply

pawn Код:
stock IsVehicleInWater(vehicleid)
{
    new Float:Float[4];
    GetVehiclePos(vehicleid,Float[0],Float[1],Float[2]);
    Float[3] = Float[2]*0.3048;
    if(Float[3] < 0) {
        return true;
    }
    return false;
}
obs: logo vou atualizar com as coords onde fica mais baixo que 0...
Reply

Hospital Spawn
Solicitado por [Dk]TuReTOo


Ao morrer ele retorna a posiзгo que morreu e fica agonizando no chгo a espera de socorro !!
Lembre-se de colocar PlayerMorreu[playerid] = false; em OnPlayerConnect para evitar supostos bugs na hora que outro player se conectar !!
pawn Код:
#include <a_samp>

new PlayerMorreu[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    if(PlayerMorreu[playerid] == true)
    {
        PlayerMorreu[playerid] = false;
        TogglePlayerControllable(playerid, 0);
        SetPlayerPos(playerid, GetPVarFloat(playerid, "PosMortoX"), GetPVarFloat(playerid, "PosMortoY"), GetPVarFloat(playerid, "PosMortoZ"));
        SetPlayerInterior(playerid, GetPVarInt(playerid, "InteriorMorto"));
        SetPlayerVirtualWorld(playerid, GetPVarInt(playerid, "VirtualWorldMorto"));
        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
        SendClientMessage(playerid, 0xFFFFFFAA, "estas a morrer, espere uma abulancia chegar para lhe salvar.");
        return 0x1;
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerMorreu[playerid] = true;
    new Float:PosMortoX, Float:PosMortoY, Float:PosMortoZ;
    GetPlayerPos(playerid, PosMortoX, PosMortoY, PosMortoZ);
    SetPVarFloat(playerid, "PosMortoX", PosMortoX);
    SetPVarFloat(playerid, "PosMortoY", PosMortoY);
    SetPVarFloat(playerid, "PosMortoZ", PosMortoZ);
    SetPVarInt(playerid, "InteriorMorto", GetPlayerInterior(playerid));
    SetPVarInt(playerid, "VirtualWorldMorto", GetPlayerVirtualWorld(playerid));
    return 1;
}
Reply

pawn Код:
new bool:Controllable[MAX_PLAYERS];

#define TogglePlayerControllableEx(%0,%1); TogglePlayerControllable(%0,%1); Controllable[%0] = %1;
#define GetPlayerControllableEx(%0) Controllable[%0]
Reply

eu hein -q


pawn Код:
#define Relize_Loop(%15) ((for(new %1=%15,%2;%1< FA/2!=%2;++%1)?(%1):(0))

Realize_Loop(i)
{
       ResetPlayerWeapons(i);
}

talvez funcione, nгo testei.
Reply

Criei um pensando no seu:

pawn Код:
#define RealizarLoop(%1, %2) for(new %1 = 0; %1 < %2; ++%1);
pawn Код:
RealizarLoop(i, 100);
{
    ResetPlayerWeapons(i);
}
Ele irб realizar um loop com 100 jogadores, й bem ъtil ao meu ponto de vista
Reply

pawn Код:
stock GetWeaponModel(weaponid)
{
    if(weaponid == 0 || weaponid == 1) return 331;
    else if(weaponid > 1 && weaponid < 9) return weaponid+331;
    else if(weaponid == 9) return 341;
    else if(weaponid > 9 && weaponid < 16) return weaponid+311;
    else if(weaponid == 16 || weaponid == 17 || weaponid == 18) return weaponid+326;
    else if(weaponid > 21 && weaponid < 30 || weaponid > 32 && weaponid < 46) return weaponid+324;
    else if(weaponid == 30 || weaponid == 31) return weaponid+325;
    else if(weaponid == 32) return 372;
    else if(weaponid == 46) return 371;
    return false;
}
Reply

pawn Код:
stock GetPlayerWeaponName(playerid)
{
    static str[21];
    switch(GetPlayerWeapon(playerid))
    {
        case 0: str = "Unarmed";
        case 1: str = "Brass Knuckles";
        case 2: str = "Golf Club";
        case 3: str = "Nite Stick";
        case 4: str = "Knife";
        case 5: str = "Baseball Bat";
        case 6: str = "Shovel";
        case 7: str = "Pool Cue";
        case 8: str = "Katana";
        case 9: str = "Chainsaw";
        case 10: str = "Purple Dildo";
        case 11: str = "Small White Vibrator";
        case 12: str = "Large White Vibrator";
        case 13: str = "Silver Vibrator";
        case 14: str = "Flowers";
        case 15: str = "Cane";
        case 16: str = "Grenade";
        case 17: str = "Tear Gas";
        case 18: str = "Molotov Cocktail";
        case 22: str = "9mm";
        case 23: str = "Silenced 9mm";
        case 24: str = "Desert Eagle";
        case 25: str = "Shotgun";
        case 26: str = "Sawn-off Shotgun";
        case 27: str = "Combat Shotgun";
        case 28: str = "Micro SMG";
        case 29: str = "MP5";
        case 30: str = "AK-47";
        case 31: str = "M4";
        case 32: str = "Tec9";
        case 33: str = "Country Rifle";
        case 34: str = "Sniper Rifle";
        case 35: str = "Rocket Launcher";
        case 36: str = "HS Rocket Launcher";
        case 37: str = "Flamethrower";
        case 38: str = "Minigun";
        case 39: str = "Satchel Charge";
        case 40: str = "Detonator";
        case 41: str = "Spraycan";
        case 42: str = "Fire Extinguisher";
        case 43: str = "Camera";
        case 44: str = "Nightvision Goggles";
        case 45: str = "Thermal Goggles";
        case 46: str = "Parachute";
    }
    return str;
}
Reply

@Strong

pawn Код:
stock IsVehicleInWater(vehicleid)
{
    static Float:Pos[3];
    GetVehiclePos(vehicleid,Pos[0],Pos[1],Pos[2]);
    return Pos[2] < -1 ?  true : false;
}
//@Nota: Alterei do Strong
Segue um teste:
PHP код:
public OnFilterScriptInit()
{
    new 
Tick GetTickCount();
    for(new 
i999999i++)
    {
        
IsVehicleInWater1(0);
    }
    
printf("[1] %d ms",GetTickCount() - Tick);
    
    
Tick GetTickCount();
    for(new 
i999999i++)
    {
        
IsVehicleInWater2(0);
    }
    
printf("[2] %d ms",GetTickCount() - Tick);
}
stock IsVehicleInWater1(vehicleid)
{
    new 
Float:Float[4];
    
GetVehiclePos(vehicleid,Float[0],Float[1],Float[2]);
    
Float[3] = Float[2]*0.3048;
    if(
Float[3] < 0) {
        return 
true;
    }
    return 
false;
}
stock IsVehicleInWater2(vehicleid)
{
    static 
Float:Pos[3];
    
GetVehiclePos(vehicleid,Pos[0],Pos[1],Pos[2]);
    return 
Pos[2] < -?  true false;
}
/*
#Resultado:
    [02:38:58] [1] 667 ms
    [02:38:59] [2] 375 ms
*/ 
#Off
Esqueci a senha da conta do meu irmгo, oh god.
Vi o garfield e alguns voltando, nгo deixei de vir ...

@Ricop522

Porque realizar um loop necessariamente vocк pensa que usamos sinal de menor?
Nгo adianta vocкs tentarem resumir o loop de forma que seja mais fбcil, de fato a pessoa terб que se adaptar a algo do tipo ..

pawn Код:
#define Loop(%0,%1,%2,%3,%4) for(new %0 = %1; %0 %2 %3; %0%4)
   
    //for(new i = 5; i > 0; i--)
    Loop(i,5,>,0,--)
    {
        printf("[Valor] %d",i);
    }
#Off
Vi sua assinatura, parabйns por ter a capacidade de rir da cara de uma pessoa que vocк mal conheceu ...
Reply

pula-pula de carros.....

pawn Код:
stock Pula_Pula(playerid)
{
       static g[3]; GetVehiclePos(GetVehicleModel(playerid),g[0],g[1],g[2]);
       SetVehiclePos(GetVehicleModel(playerid),g[0],g[1],g[2]   + 10 );  // Aonde estб o 10 tu troca pela altura.
       return 1;
}
Reply

pula-pula de pessoas.....
PHP код:
stock Pula_Pulaplayerid )
{
       static 
k]; GetPlayerPosplayeridk], k], k] );
       
SetPlayerPosplayeridk], k], k] + 10 ); // Onde estб o 10 vocк troca pela altura.
       
return true;

kk (:
Reply

Pegou este codigo do God Father ... Olha ele aqui:

PHP Code:
public ClearChatbox(playeridlines)
{
    if (
IsPlayerConnected(playerid))
    {
        for(new 
i=0i<linesi++)
        {
            
SendClientMessage(playeridCOLOR_GREY" ");
        }
    }
    return 
1;

Nem pra colocar os creditos, nй Jonas ?
Reply

Quote:
Originally Posted by Shadoww5
View Post
Pegou este codigo do God Father ... Olha ele aqui:

PHP Code:
public ClearChatbox(playeridlines)
{
    if (
IsPlayerConnected(playerid))
    {
        for(new 
i=0i<linesi++)
        {
            
SendClientMessage(playeridCOLOR_GREY" ");
        }
    }
    return 
1;

Nem pra colocar os creditos, nй Jonas ?
Quote:
Originally Posted by ScripterTroll
View Post
Um loop terб que criar variбveis e ainda terб que acrescentar +1 em cada mensagem enviada, realmente acham que й mais rбpido?

pawn Code:
//
if(!strcmp(cmdtext, "/lchat", true))
{

    if(!IsPlayerAdmin(playerid)) return false;

    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");
    SendClientMessageToAll(0xEFEFF7AA, " ");

    static string[128];

    GetPlayerName(playerid, string, MAX_PLAYER_NAME);
    format(string, sizeof(string), "SERVER: O Admin %s apagou o chat!", string);
    SendClientMessageToAll(0x0080C0AA,string);
    return true;
}
Й bem inviбvel ocupar tudo isto de linha, mas se querem otimizaзгo й isto.

Abraзos

_____
Shadow, MAX_PLAYER_NAME й muito ъtil, isto deixa o cуdigo muito mais genйrico para funcionar em caso de os desenvolvedores aumentaram o tamanho do limite do nick ..
Para deixar 100 linhas para mudar 0xF para 100, enfim

Abraзos

....


#OnTopic

IsvalidVehicle:

pawn Code:
stock IsValidVehicle(playerid, vehid)// By: [iPs]Garfield~
{
    if(!IsPlayerInAnyVehicle(playerid)) return false;
    static ModelosValidos[]=
    {
        562,565,559,561,560,575,534,567,536,411,579,602,496,518,527,589,597,419,533,526,474,545,517,410,600,
        436,580,439,549,491,445,604,507,585,587,466,492,546,551,516,467,426,547,405,409,550,566,540,421,
        529,431,438,437,420,525,552,416,433,427,490,528,407,544,470,598,596,597,599,601,428,499,609,524,578,486,406,573,
        455,588,403,514,423,414,443,515,456,422,482,530,418,572,413,440,543,583,478,554,402,542,603,475,568,504,457,483,508,429,541,415,480,434,
        506,451,555,477,400,404,489,479,442,458,558
    };
    for(new i; i < sizeof(ModelosValidos); ++i)
    {
        if(GetVehicleModel(GetVehicleID(playerid)) == ModelosValidos[i])
        {
            return true;
        }
    }
    return false;
}
...
Reply

pawn Code:
stock IsValidVehicle(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid)) return false;
    new modelid = GetVehicleModel(GetVehicleID(playerid));

    switch(modelid) {
        case 581, 523, 462, 521, 463, 522, 461, 448, 468, 586, 509,
            481, 510, 472, 473, 493, 595, 484, 430, 453,
            452, 446, 454, 445, 602, 416, 485, 568, 429, 433, 499, 424, 536, 496,
            504, 422, 609, 498, 401, 575, 518,
            402, 541, 482, 431, 438, 457, 527, 483, 524, 415, 542, 589, 437, 532,
            480, 596, 599, 597, 598, 578, 486,
            507, 562, 585, 427, 419, 587, 490, 528, 533, 544, 407, 565, 455, 530,
            526, 466, 604, 492, 474, 588, 434,
            502, 503, 494, 579, 545, 411, 546, 559, 508, 571, 400, 403, 517, 410,
            551, 500, 418, 572, 423, 414, 516,
            582, 467, 443, 470, 404, 514, 603, 600, 413, 426, 436, 547, 489, 441,
            594, 564, 515, 479, 534, 432, 505,
            442, 440, 475, 543, 605, 495, 567, 428, 405, 535, 458, 580, 439, 561,
            409, 560, 506, 601, 574, 566, 549,
            420, 459, 576, 525, 531, 408, 583, 451, 558, 552, 540, 491, 412, 478,
            421, 529, 456, 554, 477, 548, 425,
            417, 487, 497, 563, 501, 465, 447, 469, 488, 406, 573, 444, 556, 557,
            592, 577, 511, 512, 593, 520, 553,
            464, 476, 519, 460, 513, 539, 471, 435, 450, 591, 606, 607, 610, 584,
            608, 611, 590, 449:
        {
            return true;
        }
    }
    return false;
}
Reply

pawn Code:
#undef MAX_PLAYERS
#define MAX_PLAYERS __oPl()

stock __oPl()
{
 for( new i; i < 500; i++ )
 {
  if(!IsPlayerConnected(i)) return i;
 }
}
Reply

Fazendo Veiculo atravйs do Nome / ID em Dialog
pawn Code:
new
    VeiculoNomes[212][] =
{
    "Landstalker",
    "Bravura",
    "Buffalo",
    "Linerunner",
    "Pereniel",
    "Sentinel",
    "Dumper",
    "Firetruck",
    "Trashmaster",
    "Stretch",
    "Manana",
    "Infernus",
    "Voodoo",
    "Pony",
    "Mule",
    "Cheetah",
    "Ambulance",
    "Leviathan",
    "Moonbeam",
    "Esperanto",
    "Taxi",
    "Washington",
    "Bobcat",
    "Mr-Whoopee",
    "BF-Injection",
    "Hunter",
    "Premier",
    "Enforcer",
    "Securicar",
    "Banshee",
    "Predator",
    "Bus",
    "Rhino",
    "Barracks",
    "Hotknife",
    "Trailer",
    "Previon",
    "Coach",
    "Cabbie",
    "Stallion",
    "Rumpo",
    "RC-Bandit",
    "Romero",
    "Packer",
    "Monster",
    "Admiral",
    "Squalo",
    "Seasparrow",
    "Pizzaboy",
    "Tram",
    "Trailer",
    "Turismo",
    "Speeder",
    "Reefer",
    "Tropic",
    "Flatbed",
    "Yankee",
    "Caddy",
    "Solair",
    "Berkley's-RC-Van",
    "Skimmer",
    "PCJ-600",
    "Faggio",
    "Freeway",
    "RC Baron",
    "RC Raider",
    "Glendale",
    "Oceanic",
    "Sanchez",
    "Sparrow",
    "Patriot",
    "Quad",
    "Coastguard",
    "Dinghy",
    "Hermes",
    "Sabre",
    "Rustler",
    "ZR3-50",
    "Walton",
    "Regina",
    "Comet",
    "BMX",
    "Burrito",
    "Camper",
    "Marquis",
    "Baggage",
    "Dozer",
    "Maverick",
    "News Chopper",
    "Rancher",
    "FBI Rancher",
    "Virgo",
    "Greenwood",
    "Jetmax",
    "Hotring",
    "Sandking",
    "Blista-Compact",
    "Police-Maverick",
    "Boxville",
    "Benson",
    "Mesa",
    "RC-Goblin",
    "Hotring-Racer",
    "Hotring-Racer",
    "Bloodring-Banger",
    "Rancher",
    "Super GT",
    "Elegant",
    "Journey",
    "Bike",
    "Mountain Bike",
    "Beagle",
    "Cropdust",
    "Stunt",
    "Tanker",
    "RoadTrain",
    "Nebula",
    "Majestic",
    "Buccaneer",
    "Shamal",
    "Hydra",
    "FCR-900",
    "NRG-500",
    "HPV1000",
    "Cement-Truck",
    "Tow-Truck",
    "Fortune",
    "Cadrona",
    "FBI-Truck",
    "Willard",
    "Forklift",
    "Tractor",
    "Combine",
    "Feltzer",
    "Remington",
    "Slamvan",
    "Blade",
    "Freight",
    "Streak",
    "Vortex",
    "Vincent",
    "Bullet",
    "Clover",
    "Sadler",
    "Firetruck",
    "Hustler",
    "Intruder",
    "Primo",
    "Cargobob",
    "Tampa",
    "Sunrise",
    "Merit",
    "Utility",
    "Nevada",
    "Yosemite",
    "Windsor",
    "Monster-A",
    "Monster-B",
    "Uranus",
    "Jester",
    "Sultan",
    "Stratum",
    "Elegy",
    "Raindance",
    "RC-Tiger",
    "Flash",
    "Tahoma",
    "Savanna",
    "Bandito",
    "Freight",
    "Trailer",
    "Kart",
    "Mower",
    "Duneride",
    "Sweeper",
    "Broadway",
    "Tornado",
    "AT-400",
    "DFT-30",
    "Huntley",
    "Stafford",
    "BF-400",
    "Newsvan",
    "Tug",
    "Trailer",
    "Emperor",
    "Wayfarer",
    "Euros",
    "Hotdog",
    "Club",
    "Trailer-B",
    "Trailer-C",
    "Andromada",
    "Dodo",
    "RC-CaLm",
    "Launch",
    "Police Car [LSPD]",
    "Police Car [SFPD]",
    "Police Car [LVPD]",
    "Police Ranger",
    "Picador",
    "S.W.A.T",
    "Alpha",
    "Phoenix",
    "Glendale",
    "Sadler",
    "Luggage Trailer",
    "Luggage Trailer",
    "Stair Trailer",
    "Boxville",
    "Farm Plow",
    "Utility Trailer"
};
stock
    CriarVeiculo( playerid, modelid )
{
    new veiculo,Float:X,Float:Y,Float:Z,Float:X2,Float:Y2,Float:Z2,Float:Angulo;

    if ( GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
    {
        veiculo = GetPlayerVehicleID( playerid );
        GetVehiclePos( veiculo, X, Y, Z );
        GetVehicleZAngle( veiculo, Angulo );
        GetVehicleVelocity(veiculo,X2,Y2,Z2);
        DestroyVehicle( veiculo );
    }
    else
    {
        GetPlayerPos( playerid, X, Y, Z );
        GetPlayerFacingAngle( playerid, Angulo );
    }
    vehicle = AddStaticVehicle( modelid, X, Y, ( Z + 1 ), Angulo,-1,-1);
    LinkVehicleToInterior( veiculo, GetPlayerInterior( playerid ) );
    SetVehicleVirtualWorld( veiculo, GetPlayerVirtualWorld( playerid ) );
    PutPlayerInVehicle( playerid, veiculo, 0 );
    return true;
}
IsNumeric(const stringf[])
{
    for (new g = 0, kho = strlen(stringf); g < kho; g++)
    {
        if (stringf[g] > '9' || stringf[g] < '0') return 0;
    }
    return true;
}

GetVehicleModelIDFromName(Nome[])
{
    for(new i = 0; i < 211; i++)
    {
        if ( strfind(VeiculoNomes[i], Nome, true) != -1 )
        return i + 400;
    }
    return -true;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
    if(strcmp("/veiculo", cmdtext, true, 10) == 0)
    {
    ShowPlayerDialog(playerid, 1007, DIALOG_STYLE_INPUT, "Nome do Carro","Por favor Digite o nome do veiculo que vocк deseja criar.","Ok","Cancelar");
    return true;
    }
    return false;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1007)
    {
    new
            id;
    if(!IsNumeric(inputtext)) id = GetVehicleModelIDFromName(inputtext); else ida = strval(inputtext);
    if(id < 400 || id > 603) return SendClientMessage(playerid ,-1,"Modelo/Nome Invalido");
    CriarVeiculo(playerid, id);
    }
    return true;
}
Reply

Bom estava pensando em achar uma maneira de fazer um Anti-Flood sem SetTimer e sem GetTickCount() (Pois Y_Less disse que nгo й recomendado usar GetTickCount() por vбrios fatores) e entгo chegei a este cуdigo, simples mas muito ъtil.
pawn Code:
new IsFlooding[MAX_PLAYERS];
public OnPlayerText(playerid,text[])
{
    if(gettime() < IsFlooding[playerid])
        SendClientMessage(playerid,-1,"(erro) Sem flood.");
    else
    {
        IsFlooding[playerid] = gettime()+3;
        return true;
    }
    return false;
}
Bom proveito.
Reply

sDetector

Funзгo: Enviar mensagens para quem estiver perto do jogador

pawn Code:
//======================================[ sDetector ]======================================

public sDetector(Float:radi, playerid, string[], color1, color2, color3)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:Pos[3];
        GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
        for(new i = 0; i < MAX_PLAYERS; i ++)
        {
            if(IsPlayerInRangeOfPoint(i, radi, Pos[0], Pos[1], Pos[2]))
            {
                SendClientMessage(i, color1, string);
            }
            if(IsPlayerInRangeOfPoint(i, radi*2, Pos[0], Pos[1], Pos[2]) && !IsPlayerInRangeOfPoint(i, radi, Pos[0], Pos[1], Pos[2]))
            {
                SendClientMessage(i, color2, string);
            }          
            if(IsPlayerInRangeOfPoint(i, radi*3, Pos[0], Pos[1], Pos[2]) && !IsPlayerInRangeOfPoint(i, radi*2, Pos[0], Pos[1], Pos[2]))
            {
                SendClientMessage(i, color3, string);
            }
        }
    }
    return 1;
}

//======================================[ sDetector ]======================================
Reply

GetVehicles connected
exibe quantos carros tem no servidor.
pawn Code:
stock GetVehiclesConnecteds()
{
    new
        strtr[213], lol;
    for(new i; i < MAX_VEHICLES; ++i)
    {
        if(GetVehicleModel(i))
        {
            strtr[GetVehicleModel(i)-400]++;
            lol++;
        }
    }
    return lol;
}

USO:

pawn Code:
printf("Tem %d veiculos no servidor.",GetVehiclesConnecteds());
Reply


Forum Jump:


Users browsing this thread: 11 Guest(s)