Raised This Month: $ Target: $400
 0% 

AMXX Errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-15-2012 , 16:39   AMXX Errors
Reply With Quote #1

Hey there,I need a little help,I checked everything twice but couldn't figure out whats the problem

These are the errors: ( Generated in Console )

L 06/16/2012 - 01: 31:18: [FUN] Invalid player 1
L 06/16/2012 - 01: 31:18: [AMXX] Displaying debug trace (plugin "adminmode.amxx")
L 06/16/2012 - 01: 31:18: [AMXX] Run time error 10: native error (native "set_user_health")
L 06/16/2012 - 01: 31:18: [AMXX] [0] adminmode.sma::ClientSpawn (line 21)

"set_user_health" is a native from fun.inc but I am including fun,If I change it to fun.inc
It displays the same error.Help please

I am using the following code:

Code:
if (is_user_alive(id))
{
set_user_health(id, 200)
cs_set_user_armor(id, 300, CS_ARMOR_VESTHELM) // For Armor,You know that!
}
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-15-2012 , 16:49   Re: AMXX Errors
Reply With Quote #2

check is_user_connected(id)
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-15-2012 , 17:04   Re: AMXX Errors
Reply With Quote #3

I am checking:
Code:
is_user_admin(id)
Is it okay or do I have to check for user connection too O_O ?
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-15-2012 , 17:19   Re: AMXX Errors
Reply With Quote #4

Test this :

Code:
#include < amxmodx > #include < hamsandwich > #include < cstrike > #include < fun > public plugin_init( ) {     register_plugin( "test" , "1.0" , "Aooka" );         RegisterHam( Ham_Spawn , "player" , "Fw_HamSpawn" , true ); } public Fw_HamSpawn( id ) {     if( is_user_alive( id ) )     {         set_user_health( id , 200 );         cs_set_user_armor( id , 300 , CS_ARMOR_VESTHELM );     }     return 0; }
__________________
Pawn ? Useless
Aooka is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-15-2012 , 17:20   Re: AMXX Errors
Reply With Quote #5

Quote:
Originally Posted by Waleed View Post
I am checking:
Code:
is_user_admin(id)
Is it okay or do I have to check for user connection too O_O ?
not necessarily
__________________
Pawn ? Useless
Aooka is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2012 , 19:43   Re: AMXX Errors
Reply With Quote #6

Quote:
Originally Posted by Liverwiz View Post
check is_user_connected(id)
You don't need to check for connected if you are only checking for alive.

Quote:
Originally Posted by Waleed View Post
I am checking:
Code:
is_user_admin(id)
Is it okay or do I have to check for user connection too O_O ?
I believe you do have to check connection for using that function. You can test it out. Just try it on an empty slot. If you get a runtime error then you need to check if they are connected first. If it simply returns false without errors then you don't need the extra check. It all really comes down to how get_user_flags() works.
__________________
fysiks is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-16-2012 , 04:03   Re: AMXX Errors
Reply With Quote #7

Why everybody use:
Code:
fw_playerspawn //fw_ before this function
I have been using only
Code:
PlayerSpawn
PlayerAlive  // No fw_ before calling functions
Will it cause any error or is it good?
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-16-2012 , 05:37   Re: AMXX Errors
Reply With Quote #8

Quote:
Originally Posted by Waleed View Post
Why everybody use:
Code:
fw_playerspawn //fw_ before this function
I have been using only
Code:
PlayerSpawn
PlayerAlive  // No fw_ before calling functions
Will it cause any error or is it good?
We use fw_MyFunction or Fw_MyFunction or FwMyFunction etc ...
Because the function is a forward.

So what is a forward ?
Hum, it's a special function in fact.
Take a look just here : http://www.amxmodx.org/funcwiki.php?go=module&id=24

You see that for instance :

Quote:
/**
* Description: Normally called whenever an entity dies.
* Forward params: function(this, idattacker, shouldgib)
* Return type: None.
* Execute params: ExecuteHam(Ham_Killed, this, idattacker, shouldgib);
*/
Ham_Killed,
Here :
Quote:
Forward params: function(this, idattacker, shouldgib)
I don't know how to explain ... LoL

See that
__________________
Pawn ? Useless
Aooka is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-16-2012 , 06:34   Re: AMXX Errors
Reply With Quote #9

get_user_flags() doesn't check if the user is connected, so yeah, you should use is_user_connected before using get_user_flags()/is_user_admin() (or any other stock that uses get_user_flags() native) of you aren't sure if the user is in the server:

PHP Code:
tatic cell AMX_NATIVE_CALL get_user_flags(AMX *amxcell *params/* 2 param */
{
int index params[1];
 
if (
index || index gpGlobals->maxClients)
{
LogError(amxAMX_ERR_NATIVE"Invalid player id %d"index);
return 
0;
}
 
int id params[2];
 
if (
id 0)
 
id 0;
if (
id 31)
 
id 31;
 
 return 
GET_PLAYER_POINTER_I(index)->flags[id];


The name of the function doesn't matter, it's more depending on your choice and style.
__________________

Last edited by <VeCo>; 06-16-2012 at 06:34.
<VeCo> is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-16-2012 , 22:17   Re: AMXX Errors
Reply With Quote #10

Quote:
Originally Posted by Waleed View Post
Why everybody use:
Code:
fw_playerspawn //fw_ before this function
I have been using only
Code:
PlayerSpawn
PlayerAlive  // No fw_ before calling functions
Will it cause any error or is it good?
It doesn't matter what you call your function name so long as it doesn't pre-exist. Everyone has there own style, quite often based on the type / module the function / foward is or is using.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-16-2012 at 22:20. Reason: typo
hornet 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 05:49.


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