AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Slap max 2? (https://forums.alliedmods.net/showthread.php?t=3374)

Nick 07-05-2004 03:42

Slap max 2?
 
Well ok I finally got my slapall to work but it only slaps 2 people at a time.
Is it a problem with my script, or is it not possible to slap more than 2 people at once.
Code:
public slap_player(ids[]) {     new id = ids[0]         new slapdmg = (get_cvar_num("sv_slappower"))         new slapnum = (get_cvar_num("sv_numslaps"))     user_slap(id,slapdmg,slapnum)         return PLUGIN_CONTINUE } public admin_slapall(id,level,cid) {     if (!cmd_access(id,level,cid,1)){         return PLUGIN_HANDLED         }     new plist[32],pnum     get_players(plist, pnum ,"a")     for(new i=0; i<pnum; i++)     set_task(get_cvar_float("sv_slappower"),"slap_player", 0, plist, 1, "a", get_cvar_num("sv_numslaps"))     console_print(0,"All players have been slapped")     client_print(0,print_center,"All players have been slapped")     return PLUGIN_HANDLED } public amx_slappower(id,level,cid){     if (!cmd_access(id,level,cid,2))         return PLUGIN_HANDLED     new arg[8]     read_argv(1,arg,7)     if ((str_to_num(arg) > 100) || (str_to_num(arg) < 1)){         console_print(id,"[AMXX] MAX slap power is 20")                   return PLUGIN_HANDLED        }     set_cvar_string("sv_slappower",arg)     return PLUGIN_HANDLED          }     public amx_numslaps(id,level,cid){     if (!cmd_access(id,level,cid,2))         return PLUGIN_HANDLED     new arg[8]     read_argv(1,arg,7)     if ((str_to_num(arg) > 100) || (str_to_num(arg) < 2)){         console_print(id,"[AMXX] MAX slaps is 100")                   return PLUGIN_HANDLED        }     set_cvar_string("sv_numslaps",arg)     return PLUGIN_HANDLED          }
[/code]

Ryan 07-05-2004 11:06

i see you are setting a task for the actuall slapping:
Code:
set_task(get_cvar_float("sv_slappower"),"slap_player", 0, plist, 1, "a", get_cvar_num("sv_numslaps"))

the formatting for this is incorrect, as shown by the definition...

Code:
/* Calls function on specified time. * Flags: * "a" - repeat. * "b" - loop task. * "c" - do task on time after a map timeleft. * "d" - do task on time before a map timelimit. */ native set_task(Float:time,const function[],id = 0,parameter[]="",len = 0,flags[]="", repeat = 0);

you seem to be passing the damage in the time slot by mistake, which may be causing the problem(s).

you can slap everyone at once, yes :) here's one way of doing it with your current setup.

Code:
public slap_all() {          // replaces slap_player()     new slapdmg = get_cvar_num( "sv_slappower" );     new Players[32], iTotalPlayers;     get_players( Players, iTotalPlayers , "a" );     for ( new i = 0; i < iTotalPlayers; i++ )     {         new id = Players[i];         user_slap( id, slapdmg );     }     return PLUGIN_HANDLED; } public admin_slapall( id, level, cid ) {     if ( !cmd_access( id, level, cid, 1 ) )         return PLUGIN_HANDLED;     new slapnum = get_cvar_num( "sv_numslaps" ) - 1;    // we're going to slap once immediately, then set a small timer if there are any more slaps to perform.     slap_all();     if ( slapnum > 0 )     {         set_task( 0.1, "slap_all", 0, "", 0, "a", slapnum );     }     console_print( 0, "All players have been slapped" );     client_print( 0, print_center, "All players have been slapped" );     return PLUGIN_HANDLED; }

This should work :)

FroXeN 07-05-2004 15:12

have you seen amx_holyslap or amx_uberslap

its funny. :o

Burnzy 07-05-2004 15:18

ive seen uberslap... id like to see a slap that makes u glow a color, then slaps u 99 times (each with 1 damage), and then (RIGHT AFTER) makes u a rocket and u fly!!!!! (and die)

Now thats a slap!

Nick 07-05-2004 18:18

ty very much Ryan, I will try your code then test it out. :D

Nick 07-05-2004 18:42

Tested it worked like a charm.

Ryan 07-05-2004 23:32

8)

Nick 07-06-2004 22:09

this by any chance cause lots of lag and could crash server like on a 32 player?

Ryan 07-06-2004 23:48

no, because it does it's thing, then stops. if you're running milisecond tasks all the time to check for stuff, ie- with potential that they may not even stop, then yes, you're going to lag the hell out of any server. but this code, no.

Nick 07-07-2004 02:11

ok good I was thinking it might cause some lag.


All times are GMT -4. The time now is 14:45.

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