AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   some logs for plugin (https://forums.alliedmods.net/showthread.php?t=223068)

slypire 08-09-2013 13:33

some logs for plugin
 
Hi guys, I'm new in plugins world and everything like that, I have using this plugin but there is some logs from him, can anybody give me idea how to fix this, its very simple plugin.

PHP Code:

#include <amxmodx>
#include <fun>
#include <hamsandwich>
 
#define PLUGIN "Spawn Heal"
#define VERSION "1.0"
#define AUTHOR "RedRobster"
 
public plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
RegisterHam(Ham_Spawn,"player","Spawn_Hook",1)
}
 
public 
Spawn_Hook(id)
{
 if(
is_user_alive(id))
  
set_task(1.0,"Heal_User",id,_,_,"a",5)
}
public 
Heal_User(id)
{
 
set_user_health(id,100)


And log is

[AMXX] Run time error 10: native error (native "set_user_health")


Thanks a lot for help guys!

akcaliberg 08-09-2013 13:48

Re: some logs for plugin
 
You must check if the player is connected whenever you use set_task. Players can disconnect before the task ends.

Here your solution to prevent that error

PHP Code:

#include <amxmodx> 
#include <fun> 
#include <hamsandwich> 

#define PLUGIN "Spawn Heal" 
#define VERSION "1.0" 
#define AUTHOR "RedRobster" 

public plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
    
    
RegisterHam(Ham_Spawn,"player","Spawn_Hook",1


public 
Spawn_Hook(id

    
set_task(1.0,"Heal_User",id,_,_,"a",5

public 
Heal_User(id

    if(
is_user_alive(id) && is_user_connected(id)) 
    {
        
set_user_health(id,100
    }
    else 
remove_task(id)



Plus why are you setting players' health to 100 five times ? If you want to make a spawn protection, it is very poor way.

slypire 08-09-2013 14:03

Re: some logs for plugin
 
I dont know how to make spawn protection better x)
I tride Bad Spawn Preventer from xPaw and beast but its not working for me, players still get killed at start of map...

akcaliberg 08-09-2013 14:27

Re: some logs for plugin
 
this is a simple method.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>

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

#define TASKID 1119

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn,"player","HamPlayerSpawnPost",1)
    
    
register_event("DeathMsg","eDeath","a")
}
public 
HamPlayerSpawnPost(id) {
    
set_user_godmode(id1)
    
set_task(5.0,"RemoveGodmode",id+TASKID)
}
public 
eDeath() {
    new 
victim read_data(2)
    
set_user_godmode(victim,0)
    if(
task_exists(victim+TASKID)) remove_task(victim+TASKID)
}
public 
RemoveGodmode(id) {
    
id -= TASKID;
    
set_user_godmode(id,0)


But I think that is not recommended too.

Here is another method.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

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

#define TASKID 1119
#define PROTECTION_TIME 5

new LastTimeSpawned[33];
new 
iMaxPlayers;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn,"player","HamPlayerSpawn_Post",1)
    
RegisterHam(Ham_TakeDamage,"player","HamTakeDamage_Pre",0)
    
    
iMaxPlayers get_maxplayers()
}
public 
HamPlayerSpawn_Post(id) {
    
LastTimeSpawned[id] = get_systime();
}
public 
HamTakeDamage_PrevictiminflictorattackerFloat:damagetype) {
    
    if( 
<= victim <= iMaxPlayers && (get_systime() - LastTimeSpawned[victim]) <= PROTECTION_TIME  ) {
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED


It's not still the best way. I gave that methods to show you there are better ways to make a spawn protection. These can be inspiration for the beginners.

If you search you can find the advanced ones.

slypire 08-09-2013 14:49

Re: some logs for plugin
 
Thanks a lot, can I use some of these method on my DR server?
Thanks dude.

akcaliberg 08-09-2013 15:03

Re: some logs for plugin
 
of course, but as I said you can find better plugins.

slypire 08-09-2013 15:07

Re: some logs for plugin
 
Thansk a lot, Can I send u PM with one more plugin xp and levels but i need some help for fixing hud, I will send u PM if u are able and if u want to help me, thanks for this one more time.

Moderator, lock please!

YamiKaitou 08-09-2013 15:34

Re: some logs for plugin
 
FYI, your "log" is incomplete. If you look at the rest of the log, it would have told you what the problem was


All times are GMT -4. The time now is 15:50.

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