AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   drop item - help (https://forums.alliedmods.net/showthread.php?t=22511)

buildy 12-28-2005 22:03

drop item - help
 
1 Attachment(s)
im writing a awp battle script but I keep running into problems. the problem here is that the pistol gets dropped on round start, but after a player dies it doesnt work at all when they respawn.

Hawk552 12-29-2005 09:52

Try this:

Code:
#include <amxmodx> #include <cstrike> #include <fun> //================= // declare variables new players[32] new playercount, i new CsTeams:team //=================   public plugin_init() {      register_plugin("AWP Battle!", "1.0", "Buildy") // register plugin      register_logevent("round_start", 2, "0=World triggered", "1=Round_Start") //hook round start      register_event("DeathMsg", "on_Death", "a")  //hook death event      register_event("CurWeapon","pistol","be") }   public round_start() {      set_hudmessage(255, 255, 255, -1.0, 0.35, _, _, 4.3, _, _, 4)      show_hudmessage(0,"****AWP Battle****")                          // display      set_hudmessage(0, 0, 255, -1.0, -1.0, _, _, 3.7, _, _, 3)          // Awp battle      show_hudmessage(0,"Coded by:   Buildy.")                            //  greeting            server_cmd("amx_restrict on usp") // restrict weapons                  get_players(players, playercount, "a") // get list of players ids      for(i=0; i<playercount; i++)      {           //new ammo, clip, weapon = get_user_weapon(players[i], clip, ammo) // get weapon                     //if (weapon ==  16 || 17) // pistol?           //{             //team = cs_get_user_team(players[i]) // get players team             //if (team == CS_TEAM_T) // drop pistol             //{              //   client_cmd(players[i], "weapon_glock18;drop")             //} else if (team == CS_TEAM_CT)             //{              //  client_cmd(players[i], "weapon_usp;drop")             //}           //}           pistol() // remove pistol           give_item(players[i], "weapon_awp") // give everyone an awp      } }   public on_Death() {         new sPass[1]         sPass[0] = read_data(2) // player id           set_task(0.5, "spawnagain", _, sPass, 1)  // respawn         set_task(0.7, "spawnagain", _, sPass, 1)         set_task(0.7, "awp", _, sPass, 1)           // awp giveaway         pistol() } //======================== // my functions //======================== public spawnagain(sPass[]) {    spawn(sPass[0]); // spawn player by id } public awp(sPass[]) {    give_item(sPass[0], "weapon_awp") // give item awp to player by id } public pistol() {     new ammo, clip, weapon = get_user_weapon(players[i], clip, ammo) // get weapon               if (weapon ==  16 || 17) // pistol?     {         team = cs_get_user_team(players[i]) // get players team         if (team == CS_TEAM_T) // drop pistol         {             client_cmd(players[i], "weapon_glock18;drop")         } else if (team == CS_TEAM_CT)         {             client_cmd(players[i], "weapon_usp;drop")         }     } }

Xanimos 12-29-2005 09:59

Code:
if (weapon ==  16 || 17) // pistol?
needs to be
Code:
if (weapon ==  16 || weapon == 17) // pistol?
Reason: If you just have a number in an if statment it will always be true. Unless it is a 0 in which case will always be false.

Hawk552 12-29-2005 10:52

Ah, didn't notice that, sorry.


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

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