[Ajuda] Otimizaзгo
#1

Bom, eu tenho esse script que eu peguei na gringa(nгo lembro quem fez esse script) ele funciona perfeitamente !, mas to buscando um meio mas "otimizado".

Quote:

public OnPlayerConnect(playerid)
{
PreloadAnimLib(playerid, "AIRPORT");
PreloadAnimLib(playerid, "Attractors");
PreloadAnimLib(playerid, "BAR");
PreloadAnimLib(playerid, "BASEBALL");
PreloadAnimLib(playerid, "BD_FIRE");
PreloadAnimLib(playerid, "BEACH");
PreloadAnimLib(playerid, "benchpress");
PreloadAnimLib(playerid, "BF_injection");
PreloadAnimLib(playerid, "BIKED");
PreloadAnimLib(playerid, "BIKEH");
PreloadAnimLib(playerid, "BIKELEAP");
PreloadAnimLib(playerid, "BIKES");
PreloadAnimLib(playerid, "BIKEV");
PreloadAnimLib(playerid, "BIKE_DBZ");
PreloadAnimLib(playerid, "BLOWJOBZ");
PreloadAnimLib(playerid, "BMX");
PreloadAnimLib(playerid, "BOMBER");
PreloadAnimLib(playerid, "BOX");
PreloadAnimLib(playerid, "BSKTBALL");
PreloadAnimLib(playerid, "BUDDY");
PreloadAnimLib(playerid, "BUS");
PreloadAnimLib(playerid, "CAMERA");
PreloadAnimLib(playerid, "CAR");
PreloadAnimLib(playerid, "CARRY");
PreloadAnimLib(playerid, "CAR_CHAT");
PreloadAnimLib(playerid, "CASINO");
PreloadAnimLib(playerid, "CHAINSAW");
PreloadAnimLib(playerid, "CHOPPA");
PreloadAnimLib(playerid, "CLOTHES");
PreloadAnimLib(playerid, "COACH");
PreloadAnimLib(playerid, "COLT45");
PreloadAnimLib(playerid, "COP_AMBIENT");
PreloadAnimLib(playerid, "COP_DVBYZ");
PreloadAnimLib(playerid, "CRACK");
PreloadAnimLib(playerid, "CRIB");
PreloadAnimLib(playerid, "DAM_JUMP");
PreloadAnimLib(playerid, "DANCING");
PreloadAnimLib(playerid, "DEALER");
PreloadAnimLib(playerid, "DILDO");
PreloadAnimLib(playerid, "DODGE");
PreloadAnimLib(playerid, "DOZER");
PreloadAnimLib(playerid, "DRIVEBYS");
PreloadAnimLib(playerid, "FAT");
PreloadAnimLib(playerid, "FIGHT_B");
PreloadAnimLib(playerid, "FIGHT_C");
PreloadAnimLib(playerid, "FIGHT_D");
PreloadAnimLib(playerid, "FIGHT_E");
PreloadAnimLib(playerid, "FINALE");
PreloadAnimLib(playerid, "FINALE2");
PreloadAnimLib(playerid, "FLAME");
PreloadAnimLib(playerid, "Flowers");
PreloadAnimLib(playerid, "FOOD");
PreloadAnimLib(playerid, "Freeweights");
PreloadAnimLib(playerid, "GANGS");
PreloadAnimLib(playerid, "GHANDS");
PreloadAnimLib(playerid, "GHETTO_DB");
PreloadAnimLib(playerid, "goggles");
PreloadAnimLib(playerid, "GRAFFITI");
PreloadAnimLib(playerid, "GRAVEYARD");
PreloadAnimLib(playerid, "GRENADE");
PreloadAnimLib(playerid, "GYMNASIUM");
PreloadAnimLib(playerid, "HAIRCUTS");
PreloadAnimLib(playerid, "HEIST9");
PreloadAnimLib(playerid, "INT_HOUSE");
PreloadAnimLib(playerid, "INT_OFFICE");
PreloadAnimLib(playerid, "INT_SHOP");
PreloadAnimLib(playerid, "JST_BUISNESS");
PreloadAnimLib(playerid, "KART");
PreloadAnimLib(playerid, "KISSING");
PreloadAnimLib(playerid, "KNIFE");
PreloadAnimLib(playerid, "LAPDAN1");
PreloadAnimLib(playerid, "LAPDAN2");
PreloadAnimLib(playerid, "LAPDAN3");
PreloadAnimLib(playerid, "LOWRIDER");
PreloadAnimLib(playerid, "MD_CHASE");
PreloadAnimLib(playerid, "MD_END");
PreloadAnimLib(playerid, "MEDIC");
PreloadAnimLib(playerid, "MISC");
PreloadAnimLib(playerid, "MTB");
PreloadAnimLib(playerid, "MUSCULAR");
PreloadAnimLib(playerid, "NEVADA");
PreloadAnimLib(playerid, "ON_LOOKERS");
PreloadAnimLib(playerid, "OTB");
PreloadAnimLib(playerid, "PARACHUTE");
PreloadAnimLib(playerid, "PARK");
PreloadAnimLib(playerid, "PAULNMAC");
PreloadAnimLib(playerid, "ped");
PreloadAnimLib(playerid, "PLAYER_DVBYS");
PreloadAnimLib(playerid, "PLAYIDLES");
PreloadAnimLib(playerid, "POLICE");
PreloadAnimLib(playerid, "POOL");
PreloadAnimLib(playerid, "POOR");
PreloadAnimLib(playerid, "PYTHON");
PreloadAnimLib(playerid, "QUAD");
PreloadAnimLib(playerid, "QUAD_DBZ");
PreloadAnimLib(playerid, "RAPPING");
PreloadAnimLib(playerid, "RIFLE");
PreloadAnimLib(playerid, "RIOT");
PreloadAnimLib(playerid, "ROB_BANK");
PreloadAnimLib(playerid, "ROCKET");
PreloadAnimLib(playerid, "RUSTLER");
PreloadAnimLib(playerid, "RYDER");
PreloadAnimLib(playerid, "SCRATCHING");
PreloadAnimLib(playerid, "SHAMAL");
PreloadAnimLib(playerid, "SHOP");
PreloadAnimLib(playerid, "SHOTGUN");
PreloadAnimLib(playerid, "SILENCED");
PreloadAnimLib(playerid, "SKATE");
PreloadAnimLib(playerid, "SMOKING");
PreloadAnimLib(playerid, "SNIPER");
PreloadAnimLib(playerid, "SPRAYCAN");
PreloadAnimLib(playerid, "STRIP");
PreloadAnimLib(playerid, "SUNBATHE");
PreloadAnimLib(playerid, "SWAT");
PreloadAnimLib(playerid, "SWEET");
PreloadAnimLib(playerid, "SWIM");
PreloadAnimLib(playerid, "SWORD");
PreloadAnimLib(playerid, "TANK");
PreloadAnimLib(playerid, "TATTOOS");
PreloadAnimLib(playerid, "TEC");
PreloadAnimLib(playerid, "TRAIN");
PreloadAnimLib(playerid, "TRUCK");
PreloadAnimLib(playerid, "UZI");
PreloadAnimLib(playerid, "VAN");
PreloadAnimLib(playerid, "VENDING");
PreloadAnimLib(playerid, "VORTEX");
PreloadAnimLib(playerid, "WAYFARER");
PreloadAnimLib(playerid, "WEAPONS");
PreloadAnimLib(playerid, "WUZI");
PreloadAnimLib(playerid, "SAMP");
}

PreloadAnimLib(playerid, animlib[])
{
ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0 ,0);
}

Obrigado desde jб
Reply
#2

CTRL + H e no primeiro campo coloque:

Code:
PreloadAnimLib(playerid, "
no segundo:
Code:
ApplyAnimation(playerid,animlib,"
Aperte CTRL+H novamente, e no primeiro campo:
Code:
");
no campo abaixo:
Code:
",0.0,0,0,0,0 ,0);
Serб muito mais otimizado. Ou vocк pode criar uma array contendo as animaзхes e executar um loop, porйm seria andar para trбs.
Reply
#3

Quote:
Originally Posted by zSuYaNw
View Post
CTRL + H e no primeiro campo coloque:

Code:
PreloadAnimLib(playerid, "
no segundo:
Code:
ApplyAnimation(playerid,animlib,"
Aperte CTRL+H novamente, e no primeiro campo:
Code:
");
no campo abaixo:
Code:
",0.0,0,0,0,0 ,0);
Serб muito mais otimizado. Ou vocк pode criar uma array contendo as animaзхes e executar um loop, porйm seria andar para trбs.
Tendi, mais tem como tirar esses tantos de PreloadAnimLib?, parece que tб demorando mais para entrar no servidor, depois que eu coloquei isso.
Reply
#4

Quote:
Originally Posted by CezarBR
View Post
Tendi, mais tem como tirar esses tantos de PreloadAnimLib?, parece que tб demorando mais para entrar no servidor, depois que eu coloquei isso.
Ele realmente demora para carregar, leve em conta quantas livrarias estбs a carregar...podes otimizar o cуdigo, mas a demora й inevitбvel.

PHP Code:
//cria uma array com todas livrarias
new const libraries[][13] = {
    {
"AIRPORT"},
    {
"Attractors"},
    {
"BAR"}
    
//insira todas as outras livrarias, nгo esqueзa de tirar a vнrgula da ъltima chave, como acima
};
public 
OnPlayerConnect(playerid)
{
    for(new 
isizeof(libraries); i++)
        
PreloadAnimLib(playeridlibraries[i][0]);
    return 
1;

Recomendaria carregar todas as animaзхes em um timer de 1 segundo(para evitar bugs) chamado em OnPlayerSpawn, pois em OnPlayerConnect o jogador nгo estб spawnado.
Reply
#5

PHP Code:
new AnimLibraies[][] =
{
    
"AIRPORT","Attractors","BAR","BASEBALL","BD_FIRE","BEACH","benchpress","BF_injection","BIKED","BIKEH",
    
"BIKELEAP","BIKES","BIKEV","BIKE_DBZ","BLOWJOBZ","BMX","BOMBER","BOX","BSKTBALL","BUDDY","BUS","CAMERA",
    
"CAR","CARRY","CAR_CHAT","CASINO","CHAINSAW","CHOPPA","CLOTHES","COACH","COLT45","COP_AMBIENT","COP_DVBYZ",
    
"CRACK","CRIB","DAM_JUMP","DANCING","DEALER","DILDO","DODGE","DOZER","DRIVEBYS","FAT","FIGHT_B","FIGHT_C",
    
"FIGHT_D","FIGHT_E","FINALE","FINALE2","FLAME","Flowers","FOOD","Freeweights","GANGS","GHANDS","GHETTO_DB",
    
"goggles","GRAFFITI","GRAVEYARD","GRENADE","GYMNASIUM","HAIRCUTS","HEIST9","INT_HOUSE","INT_OFFICE",
    
"INT_SHOP","JST_BUISNESS","KART","KISSING","KNIFE","LAPDAN1","LAPDAN2","LAPDAN3","LOWRIDER","MD_CHASE",
    
"MD_END","MEDIC","MISC","MTB","MUSCULAR","NEVADA","ON_LOOKERS","OTB","PARACHUTE","PARK","PAULNMAC","ped",
    
"PLAYER_DVBYS","PLAYIDLES","POLICE","POOL","POOR","PYTHON","QUAD","QUAD_DBZ","RAPPING","RIFLE","RIOT",
    
"ROB_BANK","ROCKET","RUSTLER","RYDER","SCRATCHING","SHAMAL","SHOP","SHOTGUN","SILENCED","SKATE","SMOKING",
    
"SNIPER","SPRAYCAN","STRIP","SUNBATHE","SWAT","SWEET","SWIM","SWORD","TANK","TATTOOS","TEC","TRAIN","TRUCK",
    
"UZI","VAN","VENDING","VORTEX","WAYFARER","WEAPONS","WUZI"
};
public 
OnPlayerSpawn(playerid)
{
    if(!
GetPVarType(playerid"animsLoaded"))
    {
        
SetPVarInt(playerid"animsLoaded"1);
        for(new 
a=0sizeof(AnimLibraies); a++){
            
ApplyAnimation(playerid,AnimLibraies[a],"null",0.0,0,0,0,0,0);
        }
    }

Reply
#6

Quote:
Originally Posted by Bruno13
View Post
Ele realmente demora para carregar, leve em conta quantas livrarias estбs a carregar...podes otimizar o cуdigo, mas a demora й inevitбvel.

PHP Code:
//cria uma array com todas livrarias
new const libraries[][13] = {
    {
"AIRPORT"},
    {
"Attractors"},
    {
"BAR"}
    
//insira todas as outras livrarias, nгo esqueзa de tirar a vнrgula da ъltima chave, como acima
};
public 
OnPlayerConnect(playerid)
{
    for(new 
isizeof(libraries); i++)
        
PreloadAnimLib(playeridlibraries[i][0]);
    return 
1;

Recomendaria carregar todas as animaзхes em um timer de 1 segundo(para evitar bugs) chamado em OnPlayerSpawn, pois em OnPlayerConnect o jogador nгo estб spawnado.
vix, agora estб crashando :/
Reply
#7

Code:
new const g_aPreloadLibs[][] = //topo
{
	"AIRPORT","ATTRACTORS","BAR","BASEBALL","BD_FIRE","BEACH","BENCHPRESS","BF_INJECTION",
	"BIKE_DBZ","BIKED","BIKEH","BIKELEAP","BIKES","BIKEV","BLOWJOBZ","BMX","BOMBER","BOX",
	"BSKTBALL","BUDDY","BUS","CAMERA","CAR","CAR_CHAT","CARRY","CASINO","CHAINSAW","CHOPPA",
	"CLOTHES","COACH","COLT45","COP_AMBIENT","COP_DVBYZ","CRACK","CRIB","DAM_JUMP","DANCING",
	"DEALER","DILDO","DODGE","DOZER","DRIVEBYS","FAT","FIGHT_B","FIGHT_C","FIGHT_D","FIGHT_E",
	"FINALE","FINALE2","FLAME","FLOWERS","FOOD","FREEWEIGHTS","GANGS","GFUNK","GHANDS","GHETTO_DB",
	"GOGGLES","GRAFFITI","GRAVEYARD","GRENADE","GYMNASIUM","HAIRCUTS","HEIST9","INT_HOUSE",
	"INT_OFFICE","INT_SHOP","JST_BUISNESS", "KART","KISSING","KNIFE","LAPDAN1","LAPDAN2","LAPDAN3",
	"LOWRIDER","MD_CHASE","MD_END","MEDIC","MISC","MTB","MUSCULAR","NEVADA","ON_LOOKERS","OTB",
	"PARACHUTE","PARK","PAULNMAC","PED","PLAYER_DVBYS","PLAYIDLES","POLICE","POOL","POOR","PYTHON",
	"QUAD","QUAD_DBZ","RAPPING","RIFLE","RIOT","ROB_BANK","ROCKET","RUNNINGMAN","RUSTLER","RYDER",
	"SCRATCHING","SEX","SHAMAL","SHOP","SHOTGUN","SILENCED","SKATE","SMOKING","SNIPER","SNM","SPRAYCAN",
	"STRIP","SUNBATHE","SWAT","SWEET","SWIM","SWORD","TANK","TATTOOS","TEC","TRAIN","TRUCK","UZI","VAN",
	"VENDING","VORTEX","WAYFARER","WEAPONS","WOP","WUZI"
};

PreLoadAnim(playerid)
{
	new tudo = sizeof(g_aPreloadLibs);
	for(new i; i < tudo; ++i) ApplyAnimation(playerid, g_aPreloadLibs[i], "null", 4.0, 0, 0, 0, 0, 0, 1);
	return 1;
}
Reply
#8

Quote:
Originally Posted by SammyJ
View Post
PHP Code:
new AnimLibraies[][] =
{
    
"AIRPORT","Attractors","BAR","BASEBALL","BD_FIRE","BEACH","benchpress","BF_injection","BIKED","BIKEH",
    
"BIKELEAP","BIKES","BIKEV","BIKE_DBZ","BLOWJOBZ","BMX","BOMBER","BOX","BSKTBALL","BUDDY","BUS","CAMERA",
    
"CAR","CARRY","CAR_CHAT","CASINO","CHAINSAW","CHOPPA","CLOTHES","COACH","COLT45","COP_AMBIENT","COP_DVBYZ",
    
"CRACK","CRIB","DAM_JUMP","DANCING","DEALER","DILDO","DODGE","DOZER","DRIVEBYS","FAT","FIGHT_B","FIGHT_C",
    
"FIGHT_D","FIGHT_E","FINALE","FINALE2","FLAME","Flowers","FOOD","Freeweights","GANGS","GHANDS","GHETTO_DB",
    
"goggles","GRAFFITI","GRAVEYARD","GRENADE","GYMNASIUM","HAIRCUTS","HEIST9","INT_HOUSE","INT_OFFICE",
    
"INT_SHOP","JST_BUISNESS","KART","KISSING","KNIFE","LAPDAN1","LAPDAN2","LAPDAN3","LOWRIDER","MD_CHASE",
    
"MD_END","MEDIC","MISC","MTB","MUSCULAR","NEVADA","ON_LOOKERS","OTB","PARACHUTE","PARK","PAULNMAC","ped",
    
"PLAYER_DVBYS","PLAYIDLES","POLICE","POOL","POOR","PYTHON","QUAD","QUAD_DBZ","RAPPING","RIFLE","RIOT",
    
"ROB_BANK","ROCKET","RUSTLER","RYDER","SCRATCHING","SHAMAL","SHOP","SHOTGUN","SILENCED","SKATE","SMOKING",
    
"SNIPER","SPRAYCAN","STRIP","SUNBATHE","SWAT","SWEET","SWIM","SWORD","TANK","TATTOOS","TEC","TRAIN","TRUCK",
    
"UZI","VAN","VENDING","VORTEX","WAYFARER","WEAPONS","WUZI"
};
public 
OnPlayerSpawn(playerid)
{
    if(!
GetPVarType(playerid"animsLoaded"))
    {
        
SetPVarInt(playerid"animsLoaded"1);
        for(new 
a=0sizeof(AnimLibraies); a++){
            
ApplyAnimation(playerid,AnimLibraies[a],"null",0.0,0,0,0,0,0);
        }
    }

Crashou tambйm :/

@edit
Criei um gamemode limpo e nгo crashou -'
Reply
#9

Quote:
Originally Posted by CezarBR
View Post
vix, agora estб crashando :/
Faz o timer que eu falei cara, й difнcil?

PHP Code:
//cria uma array com todas livrarias 
new const libraries[][13] = { 
    {
"AIRPORT"}, 
    {
"Attractors"}, 
    {
"BAR"
    
//insira todas as outras livrarias, nгo esqueзa de tirar a vнrgula da ъltima chave, como acima 
};
forward LoadAnimations(playerid);
public 
OnPlayerConnect(playerid
{
    
SendClientMessage(playerid, -1"Aguarde, carregando animaзхes...");
    
SetTimerEx("LoadAnimations"1000false"i"playerid);
    return 
1
}
public 
LoadAnimations(playerid)
{
    for(new 
isizeof(libraries); i++) 
        
PreloadAnimLib(playeridlibraries[i][0]); 
    
SendClientMessage(playerid, -1"Animaзхes carregadas");

Ele darб uma travada de alguns segundos, mas nгo crashara...
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)