Raised This Month: $ Target: $400
 0% 

hp/ap/speed/grav wont set


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 01-12-2011 , 18:07   hp/ap/speed/grav wont set
Reply With Quote #1

I am making my first actual plugin, but I a having a bit trouble with it.

What is wrong with this is that nothing of the stuff I want to set is being set. At firs I thought it was the way I picked the player index randomly, but the client_print is working. I do get the message "Health added", and my name changes as i want it to change. It has to be the natives, or the way I am using the natives which is wrong.

The plugin isn't finished, so I do indeed know that my name wont change back.

PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <hamsandwich>
#include <fun>
//cvars
new pcvarHealth
new pcvarArmor
new pcvarSpeed
new pcvarGrav
new pcvarAnnounce
new pcvarPrefix
new RandomNum
public plugin_init()
{
 
register_plugin("Random Super player""1.0""Jelle")
 
 
//cvars
 
pcvarHealth register_cvar("super_health""200")
 
pcvarArmor register_cvar("super_armor""200")
 
pcvarSpeed register_cvar("super_speed""300")
 
pcvarGrav register_cvar("super_gravity""0.8")
 
pcvarAnnounce register_cvar("super_announce""1")
 
pcvarPrefix register_cvar("super_prefix""1")
 
 
//events
 
register_event("HLTV""round_new""a""1=0""2=0")
 
register_logevent("round_end"2"1=Round_End")
}
public 
round_new()
{
 
//get random playerid
 
RandomNum random_num(1get_playersnum())
 
 
//set super player stuff
 
set_user_health(RandomNumget_pcvar_num(pcvarHealth))
 
client_print(RandomNumprint_chat"Health added")
 
set_user_armor(RandomNumget_pcvar_num(pcvarArmor))
 
set_user_maxspeed(RandomNumget_pcvar_float(pcvarSpeed))
 
set_user_gravity(RandomNumget_pcvar_float(pcvarGrav))
 
 
//get super players name
 
new PlayerName[64]
 
get_user_name(RandomNumPlayerName63)
 
 
//Announce that player is a super player
 
if ( get_pcvar_num(pcvarAnnounce) )
 {
  
client_print(0print_chat"Watch out! %s has become a super player!"PlayerName)
 }
 
 
//set new name with prefix
 
if ( get_pcvar_num(pcvarPrefix) )
 {
  new 
prefix[] = "[Super]"
  
new FullName[64]
  
formatex(FullNamecharsmax(FullName), "%s %s"prefixPlayerName)
  
set_user_info(RandomNum"name"FullName)
 }
}
public 
round_end()
{
 
//if user is dead then just return
 
if ( !is_user_alive(RandomNum) ) return
 
 
//if user has more than 100 hp then reset to 100
 
if ( get_user_health(RandomNum) > 100 )
 {
  
set_user_health(RandomNum100)
 }
 
 
//if user has more than 100 ap then reset to 100
 
if ( get_user_armor(RandomNum) > 100 )
 {
  
set_user_armor(RandomNum100)
 }
 
 
//reset speed and gravity
 
set_user_maxspeed(RandomNum240.0)
 
set_user_gravity(RandomNum1.0)

When I disconnect from the server (I am the only one in it) it gives me this error:

Code:
Dropped [Super] [RD] Jelle from server
Reason:  Kicked
L 01/13/2011 - 00:04:58: [FUN] Invalid player 1
L 01/13/2011 - 00:04:58: [AMXX] Displaying debug trace (plugin "super_player.amxx")
L 01/13/2011 - 00:04:58: [AMXX] Run time error 10: native error (native "set_user_health")
L 01/13/2011 - 00:04:58: [AMXX]    [0] super_player.sma::round_new (line 40)
I assume this is because it can't modify on a player index which isn't connected.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
 


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 01:56.


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