AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set negative frag/score (https://forums.alliedmods.net/showthread.php?t=207309)

Rirre 02-01-2013 08:59

Set negative frag/score
 
Setting negative score/frag to the player just won't work with either set_user_frags or Ham_AddPoints way.

Doing it with Ham_AddPoints sets the player's score back to 0 (using a plugin which force the score to not go to a negative value), doesn't matter how high score the player had. And without checking the user frags, it crash the server instantly when the event gets called.
Code:
#include <amxmodx> #include <fun> #include <hamsandwich> new g_maxplayers #define IsPlayer(%1) (1 <= %1 <= g_maxplayers) public plugin_init() {     register_event("TextMsg", "HookHostageKilled", "b", "2&#Killed_Hostage")     g_maxplayers = get_maxplayers() } public HookHostageKilled(id) {     if(IsPlayer(id))     { //      ExecuteHamB(Ham_AddPoints, id, -2, true) // server crash instantly         // The killer/player's score is set to 0 even if the killer/player have 2+ score         if(get_user_frags(id) >= 2)             ExecuteHamB(Ham_AddPoints, id, -2, true)         else if(get_user_frags(id) == 1)             ExecuteHamB(Ham_AddPoints, id, -1, true)     } }

wickedd 02-01-2013 09:19

Re: Set negative frag/score
 
PHP Code:

set_user_frags(idget_user_frags(id) -3

It works for me.

ConnorMcLeod 02-01-2013 10:45

Re: Set negative frag/score
 
Last argument of AddPoints is bool:bAllowNegativeScore, so if you set it to false, it's normal it doesn't work, you have to set it to true.

Rirre 02-01-2013 16:02

Re: Set negative frag/score
 
Messed around with false and true to see if it even worked to give the player score, forgot to mention that.
That's why it is at "false" now.
Still crashing with "true".

Arkshine 02-01-2013 16:47

Re: Set negative frag/score
 
Tried ExecuteHamB(Ham_AddPoints, id, -2, true) and it works fine.


All times are GMT -4. The time now is 20:38.

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