AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Random player got tagged (https://forums.alliedmods.net/showthread.php?t=226257)

zeLentN 09-15-2013 12:53

Random player got tagged
 
Hello!

I need help with a code that make a random player gets tagged.
The chance should be 1 in 100 (1%-100) that a player gets tagged each round.


If a player is tagged, the other players get a message that reads like this:

Message: [Point Mod] "Name" has been tagged! Kill him and get a reward of "X" Points!


and for him who have been tagged should a message like this look like:

Message: [Point Mod] You have been tagged, survive the round and get a reward of "X" Points!


X Points will vary (change) between 10 to 30 Points.



I would be grateful for help.


Regards zeLentN

Black Rose 09-15-2013 13:04

Re: Random player got tagged
 
Could you link to the point mod you're using?
This should've been placed in request section. (Keep it here until a mod moves it, don't create a new thread)

zeLentN 09-15-2013 14:06

Re: Random player got tagged
 
Sorry, i mean CashMod.

Link:
http://forums.alliedmods.net/showthread.php?t=137503

Thanks.

ironskillz1 09-15-2013 14:13

Re: Random player got tagged
 
Something like this?

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <colorchat>

#define PLUGIN "Tag Random Player"
#define VERSION "1.0"
#define AUTHOR "SnusMumrikeN"

new g_iLastChoosenPlayer

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_logevent("round_start"2"1=Round_Start");
}

public 
round_start()
{        
    if (
random_num(1100) <= 1)
    {    
        
ChooseRandomPlayer()    
        
        new 
szName32 ]
        
get_user_nameg_iLastChoosenPlayerszNamecharsmaxszName ) );
        
        
ColorChat 0GREY"[Point Mod] %s has been tagged! Kill him and get a reward of 30 Points!"szName
        
ColorChat g_iLastChoosenPlayerGREY"[Point Mod] You have been tagged, survive the round and get a reward of 30 Points!"
    }    
}

/*
    -One Random player by Exolent
*/
public client_disconnect(id)
{
    if( 
g_iLastChoosenPlayer == id )
    {
        
g_iLastChoosenPlayer 0
    
}
}

ChooseRandomPlayer()
{
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum"ae""TERRORIST")
    if( 
iNum <= )
    {
        return 
iPlayers[0]
    }
    new 
iRandomNum random(iNum)
    new 
iRandomPlayer iPlayersiRandomNum ]
    if( 
iRandomPlayer == g_iLastChoosenPlayer )
    {
        
iPlayersiRandomNum ] = iPlayers[ --iNum ]
        
iRandomPlayer iPlayersrandom(iNum) ]
    }
    
g_iLastChoosenPlayer  iRandomPlayer
    
return iRandomPlayer



zeLentN 09-15-2013 15:35

Re: Random player got tagged
 
Perfect!

But how do i get "random_num" on the Points, between 0 - 30 Points?

I am using the variable g_iPoints, however.


Thanks.

~Ice*shOt 09-15-2013 15:56

Re: Random player got tagged
 
g_iPoints += random_num(0, 30)

ironskillz1 09-15-2013 16:04

Re: Random player got tagged
 
I can Edit my little plugin above
Tomrrow when i got a little more time

zeLentN 09-15-2013 16:13

Re: Random player got tagged
 
#6
Thanks

#7
That would be nice.

Black Rose 09-15-2013 17:59

Re: Random player got tagged
 
Here's what I would do.
I haven't actually tested it.
Code:
#include <amxmodx> #include <hamsandwich> #include <cashmod> new g_player; new g_points; new g_pcvar_minpoints,     g_pcvar_maxpoints,     g_pcvar_percentage; public plugin_init() {         register_plugin("Tag Random for Points", "1.0", "[ --{-@ ]");         register_logevent("logevent_RoundStart", 2, "1=Round_Start");         RegisterHam(Ham_Killed, "player", "event_HamKilled");         g_pcvar_minpoints = register_cvar("tagrandom_minpoints", "10");     g_pcvar_maxpoints = register_cvar("tagrandom_maxpoints", "30");     g_pcvar_percentage = register_cvar("tagrandom_percentage", "1"); } public logevent_RoundStart() {         if ( g_player ) {         client_print(g_player, print_chat, "[Point Mod] You have survived the round and were given a reward of %d Points!", g_points);         cm_set_user_cash(g_player, cm_get_user_cash(g_player) + g_points);     }         g_player = 0;         if ( random_num(1, 100) > get_pcvar_num(g_pcvar_percentage) )         return;         new players[32], playersnum;     get_players(players, playersnum, "ae", "TERRORIST");         g_player = players[random(playersnum)];     g_points = random_num(get_pcvar_num(g_pcvar_minpoints), get_pcvar_num(g_pcvar_maxpoints));         new name[32];     get_user_name(g_player, name, charsmax(name));         client_print(0, print_chat, "[Point Mod] %s has been tagged! Kill him and get a reward of %d Points!", name, g_points);     client_print(g_player, print_chat, "[Point Mod] You have been tagged, survive the round and get a reward of %d Points!", g_points); } public client_disconnect(id) {     if ( id == g_player )         g_player = 0; } public event_HamKilled(victim, killer) {         if ( g_player && victim == g_player && is_user_connected(killer) ) {                 new killer_name[32], victim_name[32];                 get_user_name(killer, killer_name, charsmax(killer_name));         get_user_name(victim, victim_name, charsmax(victim_name));                 client_print(0, print_chat, "[Point Mod] %s killed %s and was given a reward of %d points.", killer_name, victim_name, g_points);                 cm_set_user_cash(killer, cm_get_user_cash(killer) + g_points);     } }

zeLentN 09-16-2013 06:31

Re: Random player got tagged
 
#9

Wonderful.

I will test it as soon as I get home.


All times are GMT -4. The time now is 19:13.

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