Raised This Month: $ Target: $400
 0% 

Random player got tagged


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zeLentN
Junior Member
Join Date: Sep 2013
Location: Sweden
Old 09-15-2013 , 12:53   Random player got tagged
Reply With Quote #1

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

Last edited by zeLentN; 09-15-2013 at 13:04.
zeLentN is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-15-2013 , 13:04   Re: Random player got tagged
Reply With Quote #2

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)
__________________

Last edited by Black Rose; 09-15-2013 at 13:06.
Black Rose is offline
Old 09-15-2013, 14:01
zeLentN
This message has been deleted by zeLentN.
zeLentN
Junior Member
Join Date: Sep 2013
Location: Sweden
Old 09-15-2013 , 14:06   Re: Random player got tagged
Reply With Quote #3

Sorry, i mean CashMod.

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

Thanks.

Last edited by zeLentN; 09-15-2013 at 14:13.
zeLentN is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 09-15-2013 , 14:13   Re: Random player got tagged
Reply With Quote #4

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

__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
zeLentN
Junior Member
Join Date: Sep 2013
Location: Sweden
Old 09-15-2013 , 15:35   Re: Random player got tagged
Reply With Quote #5

Perfect!

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

I am using the variable g_iPoints, however.


Thanks.

Last edited by zeLentN; 09-15-2013 at 15:50.
zeLentN is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 09-15-2013 , 15:56   Re: Random player got tagged
Reply With Quote #6

g_iPoints += random_num(0, 30)

Last edited by ~Ice*shOt; 09-15-2013 at 15:56.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 09-15-2013 , 16:04   Re: Random player got tagged
Reply With Quote #7

I can Edit my little plugin above
Tomrrow when i got a little more time
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
zeLentN
Junior Member
Join Date: Sep 2013
Location: Sweden
Old 09-15-2013 , 16:13   Re: Random player got tagged
Reply With Quote #8

#6
Thanks

#7
That would be nice.

Last edited by zeLentN; 09-15-2013 at 16:18.
zeLentN is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-15-2013 , 17:59   Re: Random player got tagged
Reply With Quote #9

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);     } }
__________________

Last edited by Black Rose; 09-21-2013 at 12:01.
Black Rose is offline
zeLentN
Junior Member
Join Date: Sep 2013
Location: Sweden
Old 09-16-2013 , 06:31   Re: Random player got tagged
Reply With Quote #10

#9

Wonderful.

I will test it as soon as I get home.
zeLentN is offline
Reply



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 19:13.


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