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

Invalid player 0 ??


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-23-2005 , 22:46   Invalid player 0 ??
Reply With Quote #1

i keep getting this

Code:
L 09/23/2005 - 22:41:39: Invalid player id 0
L 09/23/2005 - 22:41:39: [AMXX] Displaying debug trace (plugin "SuperSheild.amxx")
L 09/23/2005 - 22:41:39: [AMXX] Run time error 10: native error (native "get_user_origin")
L 09/23/2005 - 22:41:39: [AMXX]    [0] SuperSheild.sma::client_PreThink (line 60)
and i dont know why...

i think it may because its in public client_prethink?

and i just now added the 0 parameter to get_user_origin so dont if thats it either :/

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #define PLUGIN "Super Sheild!" #define VERSION "1.0" #define AUTHOR "Zenith77" new sheildEnabled[33] new mXBeam public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_cvar( "sheild_radius", " 500 " )         register_clcmd( "amx_sheild", "activate_sheild", ADMIN_IMMUNITY, " if you dont know, dont worry " )     register_clcmd( "amx_sheild_off", "deactivate_sheild", ADMIN_IMMUNITY, " nfkasnds " ) } public plugin_precache() {         mXBeam = precache_model( "sprites/xbeam1.spr" )         } public activate_sheild(id, level, cid) {         if( !cmd_access(id ,level ,cid, 1)) {         return PLUGIN_CONTINUE     }         sheildEnabled[id] = 1         return PLUGIN_CONTINUE } public deactivate_sheild(id, level, cid) {         if( !cmd_access(id, level, cid, 1)) {         return PLUGIN_CONTINUE     }         return PLUGIN_CONTINUE     } public client_PreThink(id) {         if( sheildEnabled[id] == 1) {         for( new i = 0; i <get_maxplayers(); i++) {                         new distance, origin[3], iOrigin[3]                         get_user_origin(id, origin, 0)             get_user_origin(i, iOrigin, 0)                         distance = get_distance(origin, iOrigin)                         if( distance <= get_cvar_num("sheild_radius") ) {                                                 new iRed = random_num(0, 255)                 new iBlue = random_num(0, 255)                 new iGreen = random_num(0, 255)                                                 message_begin(MSG_BROADCAST, SVC_TEMPENTITY)                 write_byte(1)      // TE_BEAMPOINT                 write_short(id)                 write_coord(iOrigin[0])                 write_coord(iOrigin[1])                 write_coord(iOrigin[2])                 write_short(mXBeam)                 write_byte(0)                 write_byte(10)                 write_byte(10)                 write_byte(30)                 write_byte(5)                 write_byte(iRed)                 write_byte(iBlue)                 write_byte(iGreen)                 write_byte(200)                 write_byte(15)                 message_end()                                 user_kill(i, 1)             }         }     } }
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
pdoubleopdawg
Senior Member
Join Date: Aug 2005
Old 09-23-2005 , 22:47  
Reply With Quote #2

if(!is_user_connected(i)) {
return PLUGIN_HANDLED
}

Player 0 is the server.
i is getting all of the players, including the server.
pdoubleopdawg is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 09-24-2005 , 00:25  
Reply With Quote #3

Even better dont start with "new i = 0" use "new i = 1"
0 refers to the server so dont check that as a player.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
SidLuke
Senior Member
Join Date: Mar 2004
Location: Poland, Chrzanow
Old 09-24-2005 , 06:10  
Reply With Quote #4

for( new i = 0; i <get_maxplayers(); i++)
should be
for( new i = 1; i <=get_maxplayers(); i++)
__________________
Looking for DoD plugins ? Check DoD Plugins Center
SidLuke is offline
Send a message via AIM to SidLuke Send a message via MSN to SidLuke
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-24-2005 , 20:30  
Reply With Quote #5

umm ok...i added that and if id == 1 but it doesnt work. I tried changing return PLUGIN_CONTINUE to just continue but it still doesnt work....


this is what i have right now

btw, testing this with bots so dont know if thats the prob

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #define PLUGIN "Super Sheild!" #define VERSION "1.0" #define AUTHOR "Zenith77" new mXBeam public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_cvar( "sheild_radius", " 200 " )         register_clcmd( "amx_sheild", "activate_sheild", ADMIN_IMMUNITY, " if you dont know, dont worry " )     } public plugin_precache() {         mXBeam = precache_model( "sprites/xbeam1.spr" )         } public activate_sheild(id, level, cid) {         if( !cmd_access(id ,level ,cid, 1)) {         return PLUGIN_CONTINUE     }     new distance, origin[3], iOrigin[3]         get_user_origin(id, origin, 0)     for( new i = 1; i <get_maxplayers(); i++) {                 if( !is_user_connected(i) || id == i) continue                                 get_user_origin(i, iOrigin, 0)                 distance = get_distance(origin, iOrigin)                 if( distance <= get_cvar_num("sheild_radius") ) {                                     new iRed = random_num(0, 255)             new iBlue = random_num(0, 255)             new iGreen = random_num(0, 255)                         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)             write_byte(1)      // TE_BEAMPOINT             write_short(id)             write_coord(iOrigin[0])             write_coord(iOrigin[1])             write_coord(iOrigin[2])             write_short(mXBeam)             write_byte(0)             write_byte(10)             write_byte(10)             write_byte(30)             write_byte(5)             write_byte(iRed)             write_byte(iBlue)             write_byte(iGreen)             write_byte(200)             write_byte(15)             message_end()                         user_kill(i, 1) //ZOMG I GOT ELECTRICUTED!!!!!         }     }         return PLUGIN_HANDLED }
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 09-24-2005 , 20:44  
Reply With Quote #6

Quote:
Originally Posted by SidLuke
for( new i = 0; i <get_maxplayers(); i++)
should be
for( new i = 1; i <=get_maxplayers(); i++)
Zenith, you didn't do this. Note the "<=" part.
Brad is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-24-2005 , 20:58  
Reply With Quote #7

EDIT: nm works great
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 09-24-2005 , 23:09  
Reply With Quote #8

Well there are some things that you did that you shouldn't do. Yes it may work but its really improper.

You should use
Code:
new Players[32] , pnum; get_players(Players , pnum , "c"); //If you want just alive players add 'a' before the 'c'             //If you want just dead players add 'b' before the 'c'             //The 'c' makes it so it doesnt return bots for(new i = 0; i < pnum; i++) {     //Then where ever you have i in your code replace with Players[i] }

Reasons.
1) Dont call get_maxplayers() in a for loop. It just requires that that function be called ever iteration.
2) This is much more precise. It wont be called for an id of a player that is not in the server. And doesnt require an if statement after the for loop.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
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 13:10.


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