AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ready to post? (https://forums.alliedmods.net/showthread.php?t=24836)

wouter 03-03-2006 11:36

ready to post?
 
2 Attachment(s)
hi i have made some plugins and i would like to post them,
but before i do i would apreciate it if some experianced scripters check it (or it is well writen, no bug, etc.). thx for your time :up:
Code:
/* Plugin generated by AMXX-Studio */ /* With help from: Kraugh */ /* cvar: "amxx_ammoforhp" "1/0" */ /* say /ammo    to gain ammo, loose HP */ /* say_team /ammo   to gain ammo, loose HP */ #include <amxmodx> #include <fun> #include <cstrike> #define PLUGIN "ammoforhp" #define VERSION "1.0" #define AUTHOR "wouter" public plugin_init()     {       register_plugin(PLUGIN, VERSION, AUTHOR)       register_clcmd("say /ammo", "cmd_ammo")       register_clcmd("say_team /ammo", "cmd_ammo")       register_cvar("amxx_ammoforhp", "1") }     public cmd_ammo(id) {           if ( ! get_cvar_num("amxx_ammoforhp") )           return PLUGIN_HANDLED         new AmmoCost = 10     // Change how much hp you loose for the ammo     new life = get_user_health(id)          if ( !is_user_alive(id) || life <= AmmoCost) {           client_print(id, print_chat, "[AmmoForHp] You are not alive or do not have enough HP!")           return PLUGIN_HANDLED       }         new clip, ammo, weapon = get_user_weapon(id,clip,ammo);               switch(weapon) {                 case CSW_P228: {             give_item(id,"ammo_357sig")         }         case CSW_SCOUT: {             give_item(id,"ammo_762nato")         }         case CSW_HEGRENADE: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_XM1014: {             give_item(id,"ammo_buckshot")                     }         case CSW_C4: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_MAC10: {             give_item(id,"ammo_45acp")         }         case CSW_AUG: {             give_item(id,"ammo_556nato")         }         case CSW_SMOKEGRENADE: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_ELITE: {             give_item(id,"ammo_9mm")         }         case CSW_FIVESEVEN: {             give_item(id,"ammo_57mm")         }         case CSW_UMP45: {             give_item(id,"ammo_45acp")         }         case CSW_SG550: {             give_item(id,"ammo_556nato")         }         case CSW_GALIL: {             give_item(id,"ammo_308")         }         case CSW_FAMAS: {             give_item(id,"ammo_556nato")         }         case CSW_USP: {             give_item(id,"ammo_45acp")         }         case CSW_GLOCK18: {             give_item(id,"ammo_9mm")         }         case CSW_AWP: {             give_item(id,"ammo_338magnum")         }         case CSW_MP5NAVY: {             give_item(id,"ammo_9mm")         }         case CSW_M249: {             give_item(id,"ammo_556natobox")         }         case CSW_M3: {             give_item(id,"ammo_buckshot")                     }         case CSW_M4A1: {             give_item(id,"ammo_556nato")         }         case CSW_TMP: {             give_item(id,"ammo_9mm")         }         case CSW_G3SG1: {             give_item(id,"ammo_762nato")         }         case CSW_FLASHBANG: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_DEAGLE: {             give_item(id,"ammo_50ae")         }         case CSW_SG552: {             give_item(id,"ammo_556nato")         }         case CSW_AK47: {             give_item(id,"ammo_762nato")         }         case CSW_KNIFE: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_P90: {             give_item(id,"ammo_57mm")         }         default: return PLUGIN_CONTINUE     }         set_user_health(id, get_user_health(id) - AmmoCost)     client_print(id, print_chat, "[AmmoForHp] You have exchanged health for ammo!")     return PLUGIN_HANDLED }
end
Code:
/* Plugin generated by AMXX-Studio */       /* Many help form [ --<-@ ] Black Rose end ^_^Satan^_^ Thx you guys say \camouflage           // client cmd say_team \camouflage     // client cmd amxx_camouflage <1/0>   // enable / disable by admin */     #include <amxmodx>       #include <fun>       #include <cstrike>       new PLUGIN[]="Camouflage"   new AUTHOR[]="wouter"   new VERSION[]="1.00" new CamoCost = 16000  // Edit this to change the price of the Camouflage   new bool:HasCamo[33]   new CTModels[] =     {         "urban", "gsg9",       "gign", "sas"   }     new TModels[] =       {         "terror", "leet",       "artic", "guerilla"   }     public client_connect(id) {       HasCamo[id] = false   }   public plugin_init() {       register_plugin(PLUGIN, VERSION, AUTHOR)           register_event("DeathMsg", "DeathEvent", "a")       register_event("ResetHUD", "ResetHud", "a")           register_clcmd("say /camouflage", "cmd_camouflage")       register_clcmd("say_team /camouflage", "cmd_camouflage")           register_cvar("amxx_camouflage", "1")   }       public cmd_camouflage(id) {           if ( ! get_cvar_num("amxx_camouflage") )           return PLUGIN_HANDLED       new money = cs_get_user_money(id)       new CsTeams:team = cs_get_user_team(id)               if ( !is_user_alive(id) || money < CamoCost ) {           client_print(id, print_chat, "You are not alive or do not have enough money!")           return PLUGIN_HANDLED       }           if ( HasCamo[id] == false ) {                   cs_set_user_money( id, cs_get_user_money(id) - CamoCost )           client_print( id, print_chat, "You have bought a camouflage!" )           HasCamo[id] = true                   if (team == CS_TEAM_CT) {               cs_set_user_model(id, TModels)               return PLUGIN_CONTINUE;             }                   else if (team == CS_TEAM_T) {               cs_set_user_model(id, CTModels)             return PLUGIN_CONTINUE           }       }       return PLUGIN_HANDLED   }   public DeathEvent() {           if ( ! get_cvar_num("amxx_camouflage") )           return PLUGIN_HANDLED           new id = read_data(2)           if ( HasCamo[id] == true ) {         set_task( 1.0, "reset_model", id )     }     return PLUGIN_HANDLED   } public ResetHud(id) {           if ( ! get_cvar_num("amxx_camouflage") )           return PLUGIN_HANDLED           new CsTeams:team = cs_get_user_team(id)           if ( HasCamo[id] == true ) {                   if (team == CS_TEAM_CT) {               cs_set_user_model(id, TModels)           }                   else if (team == CS_TEAM_T) {               cs_set_user_model(id, CTModels)         }       }       return PLUGIN_HANDLED   } public reset_model(id) {     cs_reset_user_model(id)     HasCamo[id] = false }

[ --<-@ ] Black Rose 03-03-2006 11:49

seems to be no prob...
but bcas u have defined
Code:
new life = get_user_health(id)
you can change this :
Code:
set_user_health(id, get_user_health(id) - AmmoCost)
to this :
Code:
set_user_health(id, life - AmmoCost)

wouter 03-03-2006 16:24

ok i will. thx
but exapt that it looks nicer has it some reason to do that?

Hawk552 03-03-2006 16:26

Quote:

Originally Posted by wouter
ok i will. thx
but exapt that it looks nicer has it some reason to do that?

It's faster, since you already saved the result. Less overhead too.

[ --<-@ ] Black Rose 03-03-2006 16:26

nawh :D
it looks more professional :D

Hawk552 03-03-2006 16:27

Quote:

Originally Posted by [ --<-@
Black Rose]nawh :D
it looks more professional :D

No, you're wrong. It's faster and has less overhead.

[ --<-@ ] Black Rose 03-03-2006 16:33

i didnt know that... i must have posted like 0.001 ms after you... never saw you post :D but now i know
i thought if you wrote new life = get_user_health(id)
and every time you use life it would call the get_user_health... i don't get the differance? :P

wouter 03-03-2006 16:36

i guess it will make life equal to the command then and life is shorter then the command? :P

Hawk552 03-03-2006 16:36

That is one of the most illogical things I have seen someone here say. If that was true, this would not work:

Code:
new iWhatever = 2 iWhatever = 3 if(iWhatever == 3) // Here it would end, because you have no idea what you're talking about

wouter 03-03-2006 16:39

Quote:

Originally Posted by Hawk552
That is one of the most illogical things I have seen someone here say. If that was true, this would not work:

Code:
new iWhatever = 2 iWhatever = 3 if(iWhatever == 3) // Here it would end, because you have no idea what you're talking about

sorry for beeing noob :shock: :roll:


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

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