Raised This Month: $ Target: $400
 0% 

Need Advise/Suggestions for Plugins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-23-2012 , 15:26   Need Advise/Suggestions for Plugins
Reply With Quote #1

Hey there,I was just practising on this plugin since I am new to scripting.
I made this for my public server for practising only,But I think I need some suggestions from the seniors,
Please suggest me or tell me how to optimize this,It should help me in future.
Thanks to all.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <hamsandwich>

new objsound[] = "misc/objective.wav"

public plugin_precache()
{
    
precache_sound(objsound)
    
}



public 
plugin_init() 
{
    
register_plugin("Gameplay 1""1.0""Waleed")
    
register_clcmd("say /giveme""cmd_giveme")
    
register_clcmd("say /reset""cmd_reset")
    
register_clcmd("say /mreset""cmd_mreset")
    
RegisterHam(Ham_Killed"player""Ham_killMsg"1)
    }

public 
Ham_killMsg(id)
{
    
cs_reset_user_model id )
    if(
cs_get_user_team(id) == CS_TEAM_CT)
    {
    new 
name[32]
    
get_user_name(idnamecharsmax(name))
    
client_print(id,print_chat,"[Trooper] Man Down! Man Down! | %s has been killed!"name)
    }
    else if(
cs_get_user_team(id) == CS_TEAM_T)
    {
    new 
name[32]
    
get_user_name(idnamecharsmax(name))
    
client_print(id,print_chat,"[Commander] Man Down! Man Down! | %s has been killed!"name)
    
    }

}
    
    
public 
cmd_reset(id)
{
    
cs_set_user_deaths(id0)
    
set_user_frags(id0)
}

public 
cmd_mreset(id)
{
    new 
players[32], count 
    get_players
(playerscount"h"
    for(new 
ii<counti++) 
    { 
        
cs_set_user_deaths(players[i], 0)   
        
set_user_frags(players[i], 0)
        
client_print(0print_center,"[ADMIN] Score reset on next spawn")
    }  

}



public 
cmd_giveme(id)
{
    
    if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && cs_get_user_money(id) >= 2000){
    
    
client_cmd(id"spk misc/objective.wav")
    
cs_set_user_money(id,cs_get_user_money(id) - 2000,1)
    
strip_user_weapons(id)    
    
// Give Weapons
    
give_item(id,"weapon_knife")
    
give_item(id,"weapon_m4a1")
    
give_item(id,"weapon_deagle")
    
give_item(id"weapon_hegrenade")
    
    
// Give Ammo
    
cs_set_user_bpammo(id,22,150)
    
cs_set_user_bpammo(id,26,50)
        
    
cs_set_user_model(id,"vip")
    }
    else if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T && cs_get_user_money(id) >= 2000){
    
    
client_cmd(id"spk misc/objective.wav")
    
cs_set_user_money(id,cs_get_user_money(id) - 2000,1)
    
strip_user_weapons(id)    
    
// Give Weapons
    
give_item(id,"weapon_knife")
    
give_item(id,"weapon_ak47")
    
give_item(id,"weapon_deagle")
    
give_item(id"weapon_hegrenade")
    
    
// Give Ammo
    
cs_set_user_bpammo(id,28,150)
    
cs_set_user_bpammo(id,26,50)
    
    
cs_set_user_model(id,"vip")    
            
    
    }
    
    else     
    {
        if(
is_user_alive(id) && cs_get_user_money(id) < 2000)
        {
        
client_print(idprint_chat"[WEAPONARY] Not enough money dude,Come back later!")
        }
        else if(!
is_user_alive(id))
        {
        
client_print(idprint_chat"[MEDIC] You are dead!")
        
client_print(idprint_chat"[MEDIC] Cannot give weapons to dead players")
        }
        
        
    }

__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]

Last edited by Waleed; 06-23-2012 at 17:03. Reason: Name change a little
Waleed is offline
Send a message via Skype™ to Waleed
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-23-2012 , 17:16   Re: Need Advise/Suggestions for Plugins
Reply With Quote #2

cs_set_user_deaths(id, 0)
set_user_frags(id, 0)


Put set_user_frags(id, 0) BEFORE cs_set_user_frags(id, 0) so you don't need to wait for score update.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 06-24-2012 , 03:26   Re: Need Advise/Suggestions for Plugins
Reply With Quote #3

Code:
public cmd_mreset(id) {     for(new i; i<count; i++)       {           cs_set_user_deaths(players[i], 0)             set_user_frags(players[i], 0)         client_print(0, print_center,"[ADMIN] Score reset on next spawn")     }   }

I suggest making a new variable and then equalling it to the players[i] (create the variable before the loop) as this will prevent the compiler from overflowing (I read it HERE)

Code:
public cmd_mreset(id) {     new players[32], count, player     get_players(players, count, "h")       for(new i; i<count; i++)     {         player = players[i]         set_user_frags(player, 0)         cs_set_user_deaths(player, 0)             client_print(0, print_center,"[ADMIN] Score reset on next spawn")   // Why the index is 0 if you are looping? // it will show you the message many times as the number of players // if you just put the index to player it will print to all players // as you are collecting all (Dead+alive) from get_players()     } }

Also this
Spoiler
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.

Last edited by pokemonmaster; 06-24-2012 at 03:59.
pokemonmaster is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-24-2012 , 05:27   Re: Need Advise/Suggestions for Plugins
Reply With Quote #4

@ConnorMcLeod: Thanks for that,Deaths were set to 0 but I had to respawn again to change frags to 0 ,that should work good
@Pokemonmaster: Thanks for your advise,I will change it.

Edit:By the Way how you make spoilers ?
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]

Last edited by Waleed; 06-24-2012 at 05:28.
Waleed is offline
Send a message via Skype™ to Waleed
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-24-2012 , 05:31   Re: Need Advise/Suggestions for Plugins
Reply With Quote #5

Use SPOILER bbcode around PHP one.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Old 06-24-2012, 06:07
Waleed
This message has been deleted by Waleed.
Reply



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 06:18.


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