AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]Weapon Buying times restrict (https://forums.alliedmods.net/showthread.php?t=183312)

EDUTz 04-20-2012 13:10

[HELP]Weapon Buying times restrict
 
Hi guys. I was wondering if someone can help me modify a weapon, let's say THIS ONE ... to be more specific i wanna modify it so it can't be bought more than let's say 3 times per map ...
i have some ideas how to do it in theory, but i lack the skill to do it.

Perhaps at each load, create a txt if it doesn't exists, else delete and create another one ...
put there every AUTHID(name) and how many times that person bought the weapon ... and at each buy, check the file and give the weapon or not.

That's my theory on it, but it beats me how to do it.

Please some help !!:grrr:

claudiuhks 04-20-2012 14:18

Re: [HELP]Weapon Buying times restrict
 
Your theory is forging the server performance.

PHP Code:

new g_iBoughtTimes33 ];

public 
plugin_init( )
  
register_logevent"RoundStart"2"1=Round_Start" );

public 
client_putinserveriPlayer )
{
  
g_iBoughtTimesiPlayer ] = 0;
}

public 
client_bought_what_we_wantiPlayer )
{
  if( 
g_iBoughtTimesiPlayer ] > )
  {
    
client_printiPlayerprint_chat"This item was bought three times this round!" );

    
/* If you want to restore ammo packs */
    
zp_set_user_ammo_packsiPlayerzp_get_user_ammo_packsiPlayer ) + THIS_ITEM_PRICE );

    return 
PLUGIN_HANDLED;
  }

  
g_iBoughtTimesiPlayer ] += 1;

  return 
PLUGIN_HANDLED;
}

public 
RoundStart( )
{
  static 
i;
  for( 
1get_maxplayers( ) + 1i++ )
    
g_iBoughtTimes] = 0;



EDUTz 04-20-2012 14:51

Re: [HELP]Weapon Buying times restrict
 
din ce vad eu acolo se reseteaza la fiecare restart de runda ... in nici un caz nu tine toata harta :) oricum e un punct de plecare. revenind la engleza..

Code:

public RoundStart( )
{
  static i;
  for( i = 0; i < get_maxplayers( ) + 1; i++ )
    g_iBoughtTimes[ i ] = 0;
}

it resets every round ...

another thing ... you can't store how many times a user bought a weapon just by id(i)(iPlayer) .. maybe just for one round, but NOT for the whole map ...
for( i = 0; i < get_maxplayers( ) + 1; i++ ) ...

simply because the players come and go ... their id's change ...

claudiuhks 04-20-2012 15:22

Re: [HELP]Weapon Buying times restrict
 
PHP Code:

new g_cNames512 ][ 32 ];
new 
g_iBoughtTimes33 ];
new 
g_iRecordings;

public 
client_putinserveriPlayer 

  
g_iBoughtTimesiPlayer ] = 0

  static 
icName32 ]; get_user_nameiPlayercName31 );

  for( 
0g_iRecordingsi++ )
  {
    if( 
equalicNameg_cNames] ) ) {
        
g_iBoughtTimesiPlayer ] = 555555;

        break;
    }
  }


public 
client_is_buying_what_we_wantiPlayer 

  if( 
g_iBoughtTimesiPlayer ] > 
  { 
    
client_printiPlayerprint_chat"This item was bought three times this map!" ); 

    
/* If you want to restore ammo packs */ 
    
zp_set_user_ammo_packsiPlayerzp_get_user_ammo_packsiPlayer ) + THIS_ITEM_PRICE ); 

    return 
PLUGIN_HANDLED
  } 

  
g_iBoughtTimesiPlayer ] += 1

  if( 
g_iBoughtTimesiPlayer ] == )
  {
    
// Save him to list!

    
get_user_nameiPlayerg_cNamesg_iRecordings ], 31 );

    
g_iRecordings++;
  }

  return 
PLUGIN_HANDLED


I have not seen you wanted it for whole map. Sorry, my fault. This one will help you.

EDUTz 04-20-2012 16:03

Re: [HELP]Weapon Buying times restrict
 
te referi la ASA? // you mean this way ?

didn't test it yet, just to be sure first ...

PHP Code:

/*
[ZP] Extra Item: Golden Ak 47
Team: Humans

Description: This plugin adds a new weapon for Human Teams.
Weapon Cost: 30

Features:
- This weapon do more damage
- This weapon has zoom
- Launch Lasers
- This weapon has unlimited bullets

Credits:

KaOs - For his Dual MP5 mod

Cvars:


- zp_goldenak_dmg_multiplier <5> - Damage Multiplier for Golden Ak 47
- zp_goldenak_gold_bullets <1|0> - Golden bullets effect ?
- zp_goldenak_custom_model <1|0> - Golden ak Custom Model
- zp_goldenak_unlimited_clip <1|0> - Golden ak Unlimited Clip 

*/



#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>

#define is_valid_player(%1) (1 <= %1 <= 32)

new AK_V_MODEL[64] = "models/zombie_plague/v_golden_ak47.mdl"
new AK_P_MODEL[64] = "models/zombie_plague/p_golden_ak47.mdl"

/* Pcvars */
new cvar_dmgmultipliercvar_goldbullets,  cvar_custommodelcvar_uclip

// Item ID
new g_itemid

new bool:g_HasAk[33]

new 
g_hasZoom33 ]
new 
bullets33 ]

// Sprite
new m_spriteTexture

const Wep_ak47 = ((1<<CSW_AK47))

new 
g_cNames512 ][ 32 ];
new 
g_iBoughtTimes33 ];
new 
g_iRecordings;

public 
plugin_init()
{
    
    
/* CVARS */
    
cvar_dmgmultiplier register_cvar("zp_goldenak_dmg_multiplier""5")
    
cvar_custommodel register_cvar("zp_goldenak_custom_model""1")
    
cvar_goldbullets register_cvar("zp_goldenak_gold_bullets""1")
    
cvar_uclip register_cvar("zp_goldenak_unlimited_clip""1")
    
    
// Register The Plugin
    
register_plugin("[ZP] Extra: Golden Ak 47""1.1""AlejandroSk")
    
// Register Zombie Plague extra item
    
g_itemid zp_register_extra_item("Golden Ak 47"70ZP_TEAM_HUMAN)
    
// Death Msg
    
register_event("DeathMsg""Death""a")
    
// Weapon Pick Up
    
register_event("WeapPickup","checkModel","b","1=19")
    
// Current Weapon Event
    
register_event("CurWeapon","checkWeapon","be","1=1")
    
register_event("CurWeapon""make_tracer""be""1=1""3>0")
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)
    
// Ham TakeDamage
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
register_forwardFM_CmdStart"fw_CmdStart" )
    
}

public 
client_connect(id)
{
    
g_HasAk[id] = false
}

public 
client_putinserveriPlayer 

  
g_iBoughtTimesiPlayer ] = 0

  static 
icName32 ]; get_user_nameiPlayercName31 );

  for( 
0g_iRecordingsi++ )
  {
    if( 
equalicNameg_cNames] ) ) {
        
g_iBoughtTimesiPlayer ] = 555555;

        break;
    }
  }


public 
client_disconnect(id)
{
    
g_HasAk[id] = false
}

public 
fw_PlayerSpawn_Post(id)
{
    
g_HasAk[id] = false
}

public 
Death()
{
    
g_HasAk[read_data(2)] = false
}

public 
plugin_precache()
{
    
precache_model(AK_V_MODEL)
    
precache_model(AK_P_MODEL)
    
m_spriteTexture precache_model("sprites/dot.spr")
    
precache_sound("weapons/zoom.wav")
}

public 
zp_user_infected_post(id)
{
    if (
zp_get_user_zombie(id))
    {
        
g_HasAk[id] = false
    
}
}

public 
checkModel(id)
{
    if ( 
zp_get_user_zombie(id) )
        return 
PLUGIN_HANDLED
    
    
new szWeapID read_data(2)
    
    if ( 
szWeapID == CSW_AK47 && g_HasAk[id] == true && get_pcvar_num(cvar_custommodel) )
    {
        
set_pev(idpev_viewmodel2AK_V_MODEL)
        
set_pev(idpev_weaponmodel2AK_P_MODEL)
    }
    return 
PLUGIN_HANDLED
}

public 
checkWeapon(id)
{
    new 
plrClipplrAmmoplrWeap[32]
    new 
plrWeapId
    
    plrWeapId 
get_user_weapon(idplrClip plrAmmo)
    
    if (
plrWeapId == CSW_AK47 && g_HasAk[id])
    {
        
checkModel(id)
    }
    else 
    {
        return 
PLUGIN_CONTINUE
    
}
    
    if (
plrClip == && get_pcvar_num(cvar_uclip))
    {
        
// If the user is out of ammo..
        
get_weaponname(plrWeapIdplrWeap31)
        
// Get the name of their weapon
        
give_item(idplrWeap)
        
engclient_cmd(idplrWeap
        
engclient_cmd(idplrWeap)
        
engclient_cmd(idplrWeap)
    }
    return 
PLUGIN_HANDLED
}



public 
fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if ( 
is_user_aliveattacker ) && get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker] )
    {
        
SetHamParamFloat(4damage get_pcvar_floatcvar_dmgmultiplier ) )
    }
}

public 
fw_CmdStartiduc_handleseed )
{
    if( !
is_user_aliveid ) ) 
        return 
PLUGIN_HANDLED
    
    
if( ( get_ucuc_handleUC_Buttons ) & IN_ATTACK2 ) && !( pevidpev_oldbuttons ) & IN_ATTACK2 ) )
    {
        new 
szClipszAmmo
        
new szWeapID get_user_weaponidszClipszAmmo )
        
        if( 
szWeapID == CSW_AK47 && g_HasAk[id] == true && !g_hasZoom[id] == true)
        {
            
g_hasZoom[id] = true
            cs_set_user_zoom
idCS_SET_AUGSG552_ZOOM)
            
emit_soundidCHAN_ITEM"weapons/zoom.wav"0.202.400100 )
        }
        
        else if ( 
szWeapID == CSW_AK47 && g_HasAk[id] == true && g_hasZoom[id])
        {
            
g_hasZoomid ] = false
            cs_set_user_zoom
idCS_RESET_ZOOM)
            
        }
        
    }
    return 
PLUGIN_HANDLED
}


public 
make_tracer(id)
{
    if (
get_pcvar_num(cvar_goldbullets))
    {
        new 
clip,ammo
        
new wpnid get_user_weapon(id,clip,ammo)
        new 
pteam[16]
        
        
get_user_team(idpteam15)
        
        if ((
bullets[id] > clip) && (wpnid == CSW_AK47) && g_HasAk[id]) 
        {
            new 
vec1[3], vec2[3]
            
get_user_origin(idvec11// origin; your camera point.
            
get_user_origin(idvec24// termina; where your bullet goes (4 is cs-only)
            
            
            //BEAMENTPOINTS
            
message_beginMSG_BROADCAST,SVC_TEMPENTITY)
            
write_byte (0)     //TE_BEAMENTPOINTS 0
            
write_coord(vec1[0])
            
write_coord(vec1[1])
            
write_coord(vec1[2])
            
write_coord(vec2[0])
            
write_coord(vec2[1])
            
write_coord(vec2[2])
            
write_shortm_spriteTexture )
            
write_byte(1// framestart
            
write_byte(5// framerate
            
write_byte(2// life
            
write_byte(10// width
            
write_byte(0// noise
            
write_byte255 )     // r, g, b
            
write_byte215 )       // r, g, b
            
write_byte)       // r, g, b
            
write_byte(200// brightness
            
write_byte(150// speed
            
message_end()
        }
    
        
bullets[id] = clip
    
}
    
}

public 
zp_extra_item_selected(playeritemid)
{
    if ( 
itemid == g_itemid )
    {
        
        if( 
g_iBoughtTimesplayer ] > 
        { 
            
client_printplayerprint_chat"This item was bought three times this map!" ); 

            
/* If you want to restore ammo packs */ 
            
zp_set_user_ammo_packsplayerzp_get_user_ammo_packsplayer ) + 70 ); 

            return 
PLUGIN_HANDLED
        } 
        
        
        
        if ( 
user_has_weapon(playerCSW_AK47) )
        {
            
drop_prim(player)
        }
        
        
give_item(player"weapon_ak47")
        
g_iBoughtTimesplayer ] += 1
        
client_print(playerprint_chat"[ZP] You bought Golden Ak - 47")
        
g_HasAk[player] = true;
        
        
        if( 
g_iBoughtTimes[player ] == )
        {
            
// Save him to list!

            
get_user_nameplayerg_cNamesg_iRecordings ], 31 );

            
g_iRecordings++;
        }
        
        
        
    }
    return 
PLUGIN_HANDLED
}

stock drop_prim(id
{
    new 
weapons[32], num
    get_user_weapons
(idweaponsnum)
    for (new 
0numi++) {
        if (
Wep_ak47 & (1<<weapons[i])) 
        {
            static 
wname[32]
            
get_weaponname(weapons[i], wnamesizeof wname 1)
            
engclient_cmd(id"drop"wname)
        }
    }



claudiuhks 04-20-2012 16:05

Re: [HELP]Weapon Buying times restrict
 
That's it.

EDUTz 04-20-2012 16:55

Re: [HELP]Weapon Buying times restrict
 
multzam frumos, esti un scump!
thank you so much!
danke shon !

ps: nu merge nush de ce, da un add la edutzugaya te rog din suflet poate ma lamuresti cu ceva...
merci anticipat


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

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.