Raised This Month: $51 Target: $400
 12% 

Some help in MY Code (Knife only mod)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
--kml--
Senior Member
Join Date: Jan 2009
Old 07-17-2009 , 23:40   Some help in MY Code (Knife only mod)
Reply With Quote #1

Hello

and im back

now i have some problem in my code

PHP Code:
/* Plugin generated by Kml :O */

/*
*This plugin is a knife only mod .
*To activate it , press ~ and type ksp 1
*to disable do it vice versa as in ksp 0 .
*This plugin , when you activate it , it will remind all users that we are using this mod
*so that they wont be surprised or mad
*KSP
*Version 2.0
*Made by Tiramosu >:D
*This plugin is using VERY LESS CPU usage . 
*Good for Knife only server
*if the plugin are mulfunctioning or having bug please report .
*any Ideas or suggesting are welcomed
*And dont worry this comment wont be Included in this plugin
*comments will be ignored when they are changed into amxx 
*/


#include <amxmodx>
#include <fun>

// Plugin name
#define PLUGIN "KSP"
// Version now is 2.0 >:D
#define VERSION "2.0"
// Author :O
#define AUTHOR "TiraMushroom"
// Global Variable :O


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_cvar"ksp" "0" )
    
register_event("CurWeapon","cur_weapon","be","1=1")
    
register_clcmd("say","handle_say")
    
}

// Function for the event we registered
public cur_weapon(id)
    
{

// This is for detecting the command . ( on or off?)
new detect = (get_cvar_num("ksp"))

// using the detect . we can use switch .
switch (detect)
{
    
// is the ksp is 1? if yes continue
    
case (1):
    {        
        
// To set where the message Place is
        
set_hudmessage(422550, -1.0, -1.006.01.8)
        
// To remind Some people that we are using only knife mod
        
show_hudmessage(0"This server is using KNIFE ONLY MOD")
        
// Deleting (strip) all user weapons . So they have no weapon
        // This means their weapon is gone . It disapeared instead of throwing
        // since they have no weapon , we give them knife
        
strip_user_weapons (0);
        
give_item(0,"weapon_knife") ;
        return 
PLUGIN_HANDLED
    
}
    
    
// if it is ksp 0 then it will go through here
    
    
case (0):
    {
        
// when this is 0 , what do you want to do? so we just
        // Stops anything from this plugin to be activated.here
        // for zero
        
return PLUGIN_HANDLED;
    }
}

// After doing all that . lets stop the plugin here .
return PLUGIN_HANDLED;

}

public 
handle_say(id
{


new 
said[192]
read_args(said,192)
remove_quotes(said)

if( (
containi(said"knife") != -1) ) {
    
client_print(idprint_chat"[KSP] This server have knife mod plugin installed")
    new 
detect = (get_cvar_num("ksp"))
    
    switch (
detect)
        
    {
        case (
1):
            
        {
            
            
client_print(idprint_chat"[KSP] Knife mod is on")
        }
        
        case (
0):
            
        {
            
client_print(idprint_chat"[KSP] Knife mod is not enabled")
            return 
PLUGIN_HANDLED;
            
        }
        
    }
    
    return 
PLUGIN_CONTINUE
}
return 
PLUGIN_CONTINUE

Problem :
When Starting the plugin in console will say

L 07/18/2009 - 11:50:43: [FUN] Player out of range (0)
L 07/18/2009 - 11:50:43: [AMXX] Run time error 10 (plugin "435345435.amxx") (native "strip_user_weapons") - debug not enabled

and also it will only show hud message and wont do the Stripping and giving and also speed .

so can any1 help me?

__________________
wooT now is asking season
will ask you plenty of things for learning

Last edited by --kml--; 07-17-2009 at 23:51.
--kml-- is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-18-2009 , 00:55   Re: Some help in MY Code (Knife only mod)
Reply With Quote #2

You should be passing the id variable to both strip_user_weapons and give_item. You are currently passing 0 which not only has no connection to the player that CurWeapon was fired on, it is also an invalid player id (player id's range from 1-32). This is why you are getting the "player out of range (0)" error.

Also, you can pass a condition in register_event to check the weapon-id to make it only react when a non-knife weapon is selected\used.

PHP Code:
#include <amxmodx>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "bugsy"

new g_pEnabled;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
g_pEnabled register_cvar"ksp" "1" );
    
    
//Knife weapon id = 29
    
register_event"CurWeapon" "fw_EvCurWeapon" "be" "1=1" "2!29" );
}

public 
fw_EvCurWeaponid )
{
    if ( !
get_pcvar_numg_pEnabled ) )
        return;
        
    
set_hudmessage42 255 , -1.0 , -1.0 6.0 1.8 );
    
show_hudmessageid "This server is using KNIFE ONLY MOD" );
    
    
strip_user_weaponsid );
    
give_itemid "weapon_knife" );

__________________

Last edited by Bugsy; 07-18-2009 at 01:05.
Bugsy is offline
--kml--
Senior Member
Join Date: Jan 2009
Old 07-18-2009 , 23:30   Re: Some help in MY Code (Knife only mod)
Reply With Quote #3

Thx for Fixing and it works
and also for the information also.

Here is some crabs
__________________
wooT now is asking season
will ask you plenty of things for learning
--kml-- is offline
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 04:23.


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