Raised This Month: $ Target: $400
 0% 

Simple code doesn't work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spin7ion
Junior Member
Join Date: Dec 2007
Old 01-05-2008 , 13:21   Simple code doesn't work
Reply With Quote #1

222I couldn't understand why this code doesn't work:

//---code
#include <amxmodx>
#include <fun>
#include <engine>
#include <cstrike>

#define PLUGIN "D"
#define VERSION "1.0"
#define AUTHOR "Spin7ion"


public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("ResetHUD", "event_spawn", "a")
}
public event_spawn(id)
{
set_hudmessage(255, 255, 0, 0.60, 0.93, 0, 6.0, 12.0)
show_hudmessage(id, "D is using")
strip_user_weapons(id)
give_item(id, "weapon_p90")
}
//---code

It must give player P90 on round start.
I also try HLTV event, but it didn't work.
Please help.
Spin7ion is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-05-2008 , 13:31   Re: Simple code doesn't work
Reply With Quote #2

ResetHud is not a global event ( "a" ) ...

Try "be". http://www.amxmodx.org/funcwiki.php?...vent&go=search

But to give a weapon on round start, you should use HLTV event with a little delay.

Code:
    register_event( "HLTV", "eNew_round", "a", "1=0", "2=0" );         // [...]     public eNew_round()         set_task( 0.2, "GiveDelayed" );         public GiveDelayed()     {         static iPlayers[32], iNum;         get_players( iPlayers, iNum, "a" );                 for( new i; i < iNum; i++ )             give_item( iPlayers[i], "weapon_p90" );     }
__________________

Last edited by Arkshine; 01-05-2008 at 13:36.
Arkshine is offline
lolhax44
BANNED
Join Date: Jan 2008
Old 01-05-2008 , 16:20   Re: Simple code doesn't work
Reply With Quote #3

PHP Code:
register_event"HLTV""eNew_round""a""1=0""2=0" );
    
    
// [...]

    
public eNew_round()
        
set_task0.2"GiveDelayed" );
      
set_hudmessage(25525500.600.9306.012.0)
      
show_hudmessage(id"Everyone got a Free p90")    
    
    public 
GiveDelayed()
    {
        static 
iPlayers[32], iNum;
        
get_playersiPlayersiNum"a" );
        
        for( new 
iiNumi++ )
            
give_itemiPlayers[i], "weapon_p90" );
    } 
lolhax44 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-05-2008 , 17:31   Re: Simple code doesn't work
Reply With Quote #4

Using fakemeta instead of fun. This way is better.

Code:
        #include <amxmodx>     #include <fakemeta>         public plugin_init()         register_event( "HLTV", "eNew_round", "a", "1=0", "2=0" );     public eNew_round()         set_task( 0.2, "GiveDelayed" );         public GiveDelayed()     {         static iPlayers[32], iNum, iPid;         get_players( iPlayers, iNum, "a" );                 set_hudmessage( 255, 255, 0, 0.60, 0.93, 0, 6.0, 12.0 );                 for( new i; i < iNum; i++ )         {             iPid = iPlayers[i];             show_hudmessage( iPid, "D is using" );                         fm_strip_user_weapons( iPid );             fm_give_item( iPid, "weapon_knife" );             fm_give_item( iPid, "weapon_p90" );         }     }         fm_give_item( index, const item[] )     {         new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, item ) );                 if( !pev_valid( ent ) )             return 0;         new Float:origin[3];         pev( index, pev_origin, origin );                 set_pev( ent, pev_origin, origin );         set_pev( ent, pev_spawnflags, pev( ent, pev_spawnflags ) | SF_NORESPAWN );                 dllfunc( DLLFunc_Spawn, ent );         new save = pev( ent, pev_solid );         dllfunc( DLLFunc_Touch, ent, index );                 if( pev( ent, pev_solid ) != save )             return ent;         engfunc( EngFunc_RemoveEntity, ent );         return -1;     }         fm_strip_user_weapons( index )     {         new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "player_weaponstrip" ) );                 if( !pev_valid( ent ) )             return 0;         dllfunc( DLLFunc_Spawn, ent );         dllfunc( DLLFunc_Use, ent, index );         engfunc( EngFunc_RemoveEntity, ent );         return 1;     }
__________________
Arkshine is offline
lolhax44
BANNED
Join Date: Jan 2008
Old 01-05-2008 , 17:59   Re: Simple code doesn't work
Reply With Quote #5

You still forgot
PHP Code:
set_hudmessage(25525500.600.9306.012.0)
      
show_hudmessage(id"Everyone got a Free p90"
lolhax44 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-05-2008 , 18:00   Re: Simple code doesn't work
Reply With Quote #6

what.
__________________
Arkshine is offline
Spin7ion
Junior Member
Join Date: Dec 2007
Old 01-06-2008 , 04:26   Re: Simple code doesn't work
Reply With Quote #7

Thank you.
But I have one more question:
When I try to give player a gun, server crashes.
PHP Code:
new WeaNumb
//WeaNumb-number of weapon user selected
switch(WeaNumb)
{
case 
0:    
{
give_item(id,"weapon_ak47")
give_item(id,"ammo_ak47")
}
case 
1:
{    
give_item(id,"weapon_xm1014")
give_item(id,"ammo_xm1014")
}
case 
2:
{    
give_item(id,"weapon_m4a1")
give_item(id,"ammo_m4a1")
}
case 
3:
{    
give_item(id,"weapon_sg552")
give_item(id,"ammo_sg552")
}
case 
4:
{    
give_item(id,"weapon_elite")
give_item(id,"ammo_elite")
}
case 
5:
{    
give_item(id,"weapon_p90")
give_item(id,"ammo_p90")
}
case 
6:
{    
give_item(id,"weapon_glock18")
give_item(id,"ammo_glock18")
}
case 
7:
{    
give_item(id,"weapon_hegrenade")
}
case 
8:
{    
give_item(id,"weapon_m3")
give_item(id,"ammo_m3")
}
case 
9:
{    
give_item(id,"weapon_mac10")
give_item(id,"ammo_mac10")
}
case 
10:
{    
give_item(id,"weapon_mp5navy")
give_item(id,"ammo_mp5navy")
}
case 
11:
{    
give_item(id,"weapon_m249")
give_item(id,"ammo_m249")
}
case 
12:
{    
give_item(id,"weapon_scout")
give_item(id,"ammo_scout")
}
case 
13:
{    
give_item(id,"weapon_p228")
give_item(id,"ammo_p228")
}
case 
14:
{    
give_item(id,"weapon_aug")
give_item(id,"ammo_aug")
}
case 
15:
{    
give_item(id,"weapon_g3sg1")
give_item(id,"ammo_g3sg1")
}
case 
16:
{    
give_item(id,"weapon_deagle")
give_item(id,"ammo_deagle")
}
case 
17:
{    
give_item(id,"weapon_sig550")
give_item(id,"ammo_sig550")
}
case 
18:
{    
give_item(id,"weapon_awp")
give_item(id,"ammo_awp")
}
case 
19:
{    
give_item(id,"weapon_ump45")
give_item(id,"ammo_ump45")
}
case 
20:
{    
give_item(id,"weapon_usp")
give_item(id,"ammo_usp")
}

Why it crashes?
Spin7ion is offline
lolhax44
BANNED
Join Date: Jan 2008
Old 01-06-2008 , 06:23   Re: Simple code doesn't work
Reply With Quote #8

fm_give_item( iPid, "weapon_p90" );

You change that part of this script to

fm_give_item( iPid, "weapon_ak47" );

if you want 2 or more type

fm_give_item( iPid, "weapon_ak47" );
fm_give_item( iPid, "weapon_m4a1" );
lolhax44 is offline
lolhax44
BANNED
Join Date: Jan 2008
Old 01-06-2008 , 06:27   Re: Simple code doesn't work
Reply With Quote #9

What is the point of having

PHP Code:
            show_hudmessageiPid"D is using" ); 
D is using what does that mean
lolhax44 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-06-2008 , 11:03   Re: Simple code doesn't work
Reply With Quote #10

ammo classnames are not ammo_*
(* being weapon name)

its actually the type of ammo, not the gun its for

http://wiki.amxmodx.org/CS_Weapons_Information
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 11:00.


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