View Single Post
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-29-2015 , 13:23   Re: Skin System 2.2
Reply With Quote #8

This plugin may be cool if it would be done correctly.
PHP Code:
 Skin[31][SKINSPERWEAPONS],
vSkinMdl[31][SKINSPERWEAPONS][64], pSkinMdl[31][SKINSPERWEAPONS][64],
SkinName[31][SKINSPERWEAPONS][32], 
Instead of hardcoded customizations limit you can use dynamic arrays(or even better, tries, as key save the original weapon name), so anyone can add as much things as they want.

For your information, any array that should be used with player index must have 33 as dimension, not 31.

PHP Code:
register_event("CurWeapon","WeaponModel","be","1=1"); 
Use Ham_Item_Deploy, instead of this.

PHP Code:
get_user_name(PlayerName31); 
Use charsmax() to get string-array size.

PHP Code:
set_task(1.0"LoadPoints"Player); 
Why a delay here ?

PHP Code:
new Weapon get_user_weapon(Player); 
This initialization should be done under the check to see if player is valid.

PHP Code:
if(strlen(vSkinMdl[Weapon][x]) > 5)
set_pev(Playerpev_viewmodel2vSkinMdl[Weapon][x]);
if(
strlen(pSkinMdl[Weapon][x]) > 5)
set_pev(Playerpev_weaponmodel2pSkinMdl[Weapon][x]); 
Indent your code properly.

Using static in plugin_precache(which is called only one time) is useless.
read_file is deprecated native, use new file natives. You should also check if model path is fully valid(it has models/player/model_name and also .mdl extension) and if it exists on the server before precaching it(file_exists can do the job).

If I'm not wrong, you read the skin file two times. Why ?
Instead of intializing new strings, parse directly with vSkinMdl[Num][Already[Num]], so you won't have to call copy.

PHP Code:
new Motd[1024], Line[256];
    
formatex(Line255"<body bgcolor=^"black^">^n<font color=^"red^">^n");
    
add(Motd1023Line255);
    
formatex(Line255"<p align=^"center^">%s %s by: %s</p></font>^n<font color=^"greenyellow^">^n"PLUGINVERSIONAUTHOR);
    
add(Motd1023Line255); 
This just get repedeted every time. For me, it seems that you should do this one time, and add later the things that are context dependent(I mean that can get changed).

Don't acces cvar values inside a loop, cache it before.

There are other improvements that can be done, but this is something to start with(the most obvious mistakes).
__________________
HamletEagle is offline