Raised This Month: $9 Target: $400
 2% 

Solved Skin System Weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Robbin
Junior Member
Join Date: May 2020
Location: Aveiro, Portugal
Old 05-09-2020 , 16:41   Skin System Weapon
Reply With Quote #1

I need help!
Author is inactive
https://forums.alliedmods.net/showthread.php?t=262077

All weapon skins work except for: P90
for some reason the command to add as skin does not work.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>

#define SAVETIME_MIN 0.5
#define SAVETIME_MAX 3.0
#define LOADTIME 2.5

#define MAXWEAPONS 30
#define SKINSPERWEAPONS 10
#define POINTSLEN 6

#define PORT 1

#pragma semicolon 1

new const PLUGIN[] = "Skin System";
new const 
VERSION[] = "2.33";
new const 
AUTHOR[] = "DeRoiD";

new 
KillPoints[31][33], Skin[31][SKINSPERWEAPONS],
vSkinMdl[31][SKINSPERWEAPONS][64], pSkinMdl[31][SKINSPERWEAPONS][64],
SkinName[31][SKINSPERWEAPONS][32], Already[31], Cvar_SavepSave[3][32][33];
new 
PointsFile[64], SkinsFile[64];

new const 
WeaponNames[][] =
{
    
"""P228""""Scout""He Grenade""XM1014""""MAC10""AUG",
    
"""Elite""FiveSeven""UMP45""SG550""Galil""FAMAS",
    
"USP""Glock18""AWP""MP5""M249""M3""M4A1""TMP""G3SG1",
    
"""Deagle""SG552""AK47""Knife""P90"
};
new const 
WeaponEntNames[][] =
{
    
"weapon_p228""weapon_scout""weapon_hegrenade""weapon_xm1014""weapon_mac10",
    
"weapon_aug""weapon_elite""weapon_fiveseven""weapon_ump45""weapon_sg550",
    
"weapon_galil""weapon_famas""weapon_usp""weapon_glock18""weapon_awp",
    
"weapon_mp5navy""weapon_m249""weapon_m3""weapon_m4a1""weapon_tmp",
    
"weapon_g3sg1""weapon_deagle""weapon_sg552""weapon_ak47""weapon_knife""weapon_p90"
};

public 
plugin_init()
{    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_cvar(PLUGINAUTHORFCVAR_SERVER);
    
    
Cvar_Save register_cvar("skin_s_savemod""2");
    
    
register_clcmd("say""Say");
    
register_clcmd("say_team""Say");
    
    for(new 
NumNum sizeof WeaponEntNamesNum++)
    {
        
RegisterHam(Ham_Item_DeployWeaponEntNames[Num], "WeaponModel"1);
    }
    
    
register_forward(FM_ClientUserInfoChanged"NameChange");
    
register_dictionary("skinsystem.txt");
    
    
LoadSkins();
}
public 
plugin_precache() {
    static 
ConfigsDir[64]; 
    
get_localinfo("amxx_configsdir"ConfigsDir63);
    
formatex(PointsFile63"%s/skinsystem/save.ini"ConfigsDir);
    
formatex(SkinsFile63"%s/skinsystem/skins.cfg"ConfigsDir);
    
    new 
LenLine[256], Data[3][48], FileLine;
    
FileLine file_size(SkinsFile1);
    for(new 
Num 0Num FileLineNum++)
    {
        
read_file(SkinsFileNumLine255Len);
        
parse(LineData[0], 31Data[1], 47Data[2], 47);
        
        if(
Line[0] == ';' || strlen(Line) < 5)
            continue;

        
remove_quotes(Data[1]);
        
remove_quotes(Data[2]);
        
        if(
containi(Data[1], ".mdl") != -1)
        {
            
precache_model(Data[1]);
        }
                    
        if(
containi(Data[2], ".mdl") != -1)
        {
            
precache_model(Data[2]);
        }
    }
}
public 
NameChange(Player
{
    if(!
is_user_connected(Player) || get_pcvar_num(Cvar_Save) != 0)
        return 
FMRES_IGNORED;

    new 
OldName[32], NewName[32], Name[32];
    
get_user_name(PlayerName31);
    
pev(Playerpev_netnameOldNamecharsmax(OldName));
    if(
OldName[0])
    {
        
get_user_info(Player"name"NewNamecharsmax(NewName));
        if(!
equal(OldNameNewName))
        {
            
remove_task(Player);
            
            
LoadPlayer(Player);
            
LoadPoints(Player);
        }
    }
    return 
FMRES_IGNORED;
}
public 
WeaponModel(Weapon) {
    new 
Player get_pdata_cbase(Weapon414);
    new 
WeaponID cs_get_weapon_id(Weapon);
    
    if(
Player 32 || Player 1
    
|| WeaponID || WeaponID 30)
    {
        return 
HAM_SUPERCEDE;
    }
    
    for(new 
Num 1Num MAXWEAPONSNum++)
    {
        if(
Num == WeaponID)
        {
            for(new 
xAlready[WeaponID]; x++)
            {
                if(
KillPoints[WeaponID][Player] >= Skin[WeaponID][x])
                {
                    if(
containi(vSkinMdl[WeaponID][x], ".mdl") != -1)
                    {
                        
set_pev(Playerpev_viewmodel2vSkinMdl[WeaponID][x]);
                    }
                    if(
containi(pSkinMdl[WeaponID][x], ".mdl") != -1)
                    {
                        
set_pev(Playerpev_weaponmodel2pSkinMdl[WeaponID][x]);
                    }
                }
            }
        }
    }
    return 
HAM_IGNORED;
}
public 
LoadSkins() {
    new 
File;
    
File fopen(SkinsFile"rt");
    
    if(
File)
    {
        new 
Line[256], Type[32], Data[5][64];
        while(!
feof(File))
        {
            
fgets(FileLine255);
            
            if(
Line[0] == ';' || strlen(Line) < 5)
                continue;
                
            
parse(LineType31);
            
            for(new 
Num 1Num MAXWEAPONS+1Num++)
            {
                if(
Already[Num] >= SKINSPERWEAPONS)
                    continue;
                
                if(
equali(TypeWeaponNames[Num]))
                {
                    
parse(LineData[0], 63Data[1], 63Data[2], 63Data[3], 63Data[4], 63);
                    
copy(vSkinMdl[Num][Already[Num]], 63Data[1]);
                    
copy(pSkinMdl[Num][Already[Num]], 63Data[2]);
                    
copy(SkinName[Num][Already[Num]], 31Data[4]);
                    
Skin[Num][Already[Num]] = str_to_num(Data[3]);
                    
Already[Num]++;
                }
            }
        }
        
fclose(File);
    }
}
public 
client_death(KillerVictimWeapon)
{
    if(
Killer == Victim
    
|| Killer 32 || Killer 1
    
|| Weapon == 25 || Weapon == 9
    
|| Weapon || Weapon 30)
    {
        return 
PLUGIN_HANDLED;
    }
    
    
set_task(random_float(SAVETIME_MINSAVETIME_MAX), "SavePoints"Killer);
    
KillPoints[Weapon][Killer]++;
    
    return 
PLUGIN_CONTINUE;
}
public 
ShowSkins(Playeri)
{
    new 
MotdTitle[64];
    
formatex(MotdTitle63"%L"LANG_SERVER"MOTD1");
    
    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);
    
formatex(Line255"<p align=^"center^">%L:</p></font>^n"LANG_SERVER"SKINS"WeaponNames[i]);
    
add(Motd1023Line255);
    
formatex(Line255"<h5>^n<font color=^"white^">^n");
    
add(Motd1023Line255);
    
    for(new 
NumNum MAXWEAPONSNum++)
    {
        if(
Num != i)
        continue;
        
formatex(Line255"<p>");
        
add(Motd1023Line255);
        for(new 
xSKINSPERWEAPONSx++)
        {
            if(
strlen(SkinName[Num][x]) < 2)
                continue;
            
            
formatex(Line255"<br>%s: (%L)"SkinName[Num][x], LANG_SERVER"KILLS"Skin[Num][x]);
            
add(Motd1023Line255);
        }
        
formatex(Line255"</p>");
        
add(Motd1023Line255);
    }
    
    
formatex(Line255"^n</h5>^n</font>^n</body>");
    
add(Motd1023Line255);
    
show_motd(PlayerMotdMotdTitle);
}
public 
ShowPoints(PlayerTarget)
{
    new 
Name[32], MotdTitle[64];
    
get_user_name(TargetName31);
    
    
formatex(MotdTitle63"%L"LANG_SERVER"PKILLS"Name);
    
    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=^"white^">^n"PLUGINVERSIONAUTHOR);
    
add(Motd1023Line255);
    
formatex(Line255"<p align=^"center^">%L:</p></font>^n"LANG_SERVER"PKILLS"Name);
    
add(Motd1023Line255);
    
formatex(Line255"<font color=^"cyan^">^n");
    
add(Motd1023Line255);
    
formatex(Line255"<h5>^n");
    
add(Motd1023Line255);
 
    if(
Target 0)
    {
        
formatex(Line255"<p align=^"center^">");
        
add(Motd1023Line255);
        new 
Len;
        for(new 
Num 1Num MAXWEAPONS+1Num++)
        {
            if(
Num == || Num == || Num == || Num == 25)
            {
                continue;
            }
            
            
Len++;
            
            if(
Len POINTSLEN)
            {
                
formatex(Line255" %s: %d |"WeaponNames[Num], KillPoints[Num][Target]);
                
add(Motd1023Line255);
            }
            else
            {
                
Len 0;
                
formatex(Line255" %s: %d</p>^n<p align=^"center^">"WeaponNames[Num], KillPoints[Num][Target]);
                
add(Motd1023Line255);
            }
        }
        
formatex(Line255"</p>");
        
add(Motd1023Line255);
    }
    
    
formatex(Line255"^n</h5>^n</font>^n</body>");
    
add(Motd1023Line255);
    
show_motd(PlayerMotdMotdTitle);
}
public 
Say(Player)
{
    new 
Message[32];
    
read_args(Message31);
    
remove_quotes(Message);
    
    if(
equali(Message"/mykills"))
    {
        
ShowPoints(PlayerPlayer);
    }
    else if(
containi(Message"/skins") != -1)
    {
        for(new 
NumNum MAXWEAPONS+1Num++)
        {
            if(
containi(MessageWeaponNames[Num]) != -1)
            {
                
ShowSkins(PlayerNum);
                return 
PLUGIN_HANDLED;
            }
        }
    }
    else
    {
        new 
TargetName[32], Name[32], Command[32];
        
parse(MessageCommand31TargetName31);
        if(
equali(Command"/kill"))
        {
            for(new 
TargetTarget 32Target++)
            {
                if(
Target == Player || !is_user_connected(Target))
                {
                    continue;
                }
                
                
get_user_name(TargetName31);
                
                if((
containi(NameTargetName) != -1))
                {
                    if(
equali(NameTargetName))
                    
ShowPoints(PlayerTarget);
                    else if(
strlen(TargetName) > 3)
                    
ShowPoints(PlayerTarget);
                    return 
PLUGIN_HANDLED;
                }
            }
        }
    }
    return 
PLUGIN_CONTINUE;
}
public 
client_putinserver(Player)
{
    
remove_task(Player);
    
set_task(LOADTIME"LoadPoints"Player);
}
public 
client_connect(Player)
{
    
LoadPlayer(Player);
}
public 
LoadPoints(Player)
{
    if(!
is_user_connected(Player))
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
File;
    
File fopen(PointsFile"rt");
    
    if(
File)
    {
        new 
Line[256];
        new 
LineName[32], Data[31][8];
        
        while(!
feof(File))
        {
            
fgets(FileLine255);
            
            if(
Line[0] == ';' || strlen(Line) < 2)
                continue;
                
            
parse(LineLineName31);
            
            if(
equal(LineNamepSave[get_pcvar_num(Cvar_Save)][Player]))
            {
                
parse(LineData[0], 7Data[1], 7Data[2], 7Data[3], 7Data[4], 7Data[5], 7,
                
Data[6], 7Data[7], 7Data[8], 7Data[9], 7Data[10], 7Data[11], 7Data[12], 7,
                
Data[13], 7Data[14], 7Data[15], 7Data[16], 7Data[17], 7Data[18], 7Data[19], 7,
                
Data[20], 7Data[21], 7Data[22], 7Data[23], 7Data[24], 7Data[25], 7Data[26], 7,
                
Data[27], 7Data[28], 7Data[29], 7Data[30], 7);
                
                for(new 
Num 1Num MAXWEAPONS+1Num++)
                {
                    
KillPoints[Num][Player] = str_to_num(Data[Num]);
                }
                return 
PLUGIN_HANDLED;
            }
        }
        
fclose(File);
    }
    return 
PLUGIN_CONTINUE;
}
public 
SavePoints(Player)
{
    if(!
is_user_connected(Player))
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
File;
    
File fopen(PointsFile"rt");
    
    if(
File)
    {
        new 
Line[192], LineNum;
        
        new 
LineName[32], bool:Found;
        
        while(!
feof(File))
        {
            
fgets(FileLine191);
            
            if(
Line[0] == ';' || strlen(Line) < 2)
                continue;
                
            
parse(LineLineName31);
            
            if(
equal(LineNamepSave[get_pcvar_num(Cvar_Save)][Player]) && !Found)
            {
                new 
SaveLine[256], PlayerPoints[256], String[8];
                
                for(new 
Num 1Num MAXWEAPONS+1Num++)
                {
                    
format(String7"^"%i^" "KillPoints[Num][Player]);
                    
add(PlayerPoints255String);
                }
                
                
formatex(SaveLine255"^"%s^" %s"pSave[get_pcvar_num(Cvar_Save)][Player], PlayerPoints);
                
write_file(PointsFileSaveLineLineNum);
                
Found true;
                return 
PLUGIN_HANDLED;
            }
            
            
LineNum++;
        }
        
        if(!
Found)
        {
            new 
SaveLine[256], PlayerPoints[256], String[8];
                
            for(new 
NumNum MAXWEAPONSNum++)
            {
                
format(String7"^"%i^" "KillPoints[Num][Player]);
                
add(PlayerPoints255String);
            }
            
            
formatex(SaveLine255"^"%s^" %s"pSave[get_pcvar_num(Cvar_Save)][Player], PlayerPoints);
            
write_file(PointsFileSaveLine);
            return 
PLUGIN_HANDLED;
        }
        
fclose(File);
    }
    return 
PLUGIN_CONTINUE;
}
stock LoadPlayer(Player)
{
    new 
Num;
    for(
Num 1Num MAXWEAPONS+1Num++)
    {
        
KillPoints[Num][Player] = 0;
    }
    
    for(
Num 0Num 2Num++)
    {
        
pSave[0][Player] = "";
    }
    
get_user_name(PlayerpSave[0][Player], 31);
    
get_user_ip(PlayerpSave[1][Player], 31PORT);
    
get_user_authid(PlayerpSave[2][Player], 31);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
*/ 
The code looks clean
Sorry my poor english

Last edited by Robbin; 06-06-2020 at 18:07.
Robbin is offline
Naeciof
Junior Member
Join Date: Oct 2016
Location: Brazil
Old 06-06-2020 , 00:22   Re: Skin System Weapon
Reply With Quote #2

Change line 125
Code:
for(new Num = 1; Num < MAXWEAPONS; Num++)
for this
Code:
for(new Num = 1; Num < MAXWEAPONS+1; Num++)
Naeciof is offline
Robbin
Junior Member
Join Date: May 2020
Location: Aveiro, Portugal
Old 06-06-2020 , 18:03   Re: Skin System Weapon
Reply With Quote #3

Man now everything works
Thanksssss
Robbin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:30.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode