Raised This Month: $ Target: $400
 0% 

random msg


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FlyingHorse
Senior Member
Join Date: Apr 2010
Location: Under your bed.
Old 06-08-2010 , 09:42   random msg
Reply With Quote #1

Why wont this work?

PHP Code:
#include <amxmodx>
#include <colorchat>

#define MAX_MSG 4

new const PLUGIN[ ] = "Advertisements"
new const VERSION[ ] = "1.0"
new const AUTHOR[ ] = "FlyingHorse"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
}
public 
client_putinserver(id)
{
    
    
set_task(10.0"advertisements"id)
}

public 
advertisements(id)
{
    switch (
random_num(1MAX_MSG))
    {
        case 
1:
        {
            
            
ColorChat(idRED"lol")
        }
        case 
2:
        {
            
ColorChat(idRED"blah")
        }
        case 
3:
        {
            
ColorChat(idRED"Drekes has a ponytail!")
        }
        case 
4:
        {
            
ColorChat(idRED"omfg")
        }
    }
    
set_task(20.0"advertisements"id)


Last edited by FlyingHorse; 06-08-2010 at 09:47.
FlyingHorse is offline
Send a message via Skype™ to FlyingHorse
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 06-09-2010 , 02:10   Re: random msg
Reply With Quote #2

do it this way. much more better way.

PHP Code:
/*
*    -----------------
*     Coded in 2010, 
*     Shuttle_Wave
*     -----------------
*     
*    .:: Description ::.
*     
*     Advertisement Plugin
*
*    .:: Contacts ::.
*
*    Email: [email protected]
*
*    Steam: shuttle_wave or lengjonathon

*/
#pragma semicolon 1

#include <amxmodx>

// Define the Plugin Version
new const VERSION[] = { "1.0" };

new 
p_Advertisement;

public 
plugin_init()
{
    
register_plugin("Advertise Plugin."VERSION"Shuttle_Wave");
    
    
p_Advertisement    register_cvar("server_advert_time",    "180.0");

    if( 
get_pcvar_float(p_Advertisement) > 0.0 )
        
set_task(get_pcvar_float(p_Advertisement), "taskAdvertise"___"b");
}

public 
taskAdvertise()
{
    
client_printc(0"Advertisement Plugin Testing by Shuttle_Wave");
}

// Colour Chat
stock client_printc(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!g""^x04"); // Green Color
    
replace_all(msg190"!n""^x01"); // Default Color
    
replace_all(msg190"!t""^x03"); // Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }

__________________
JailBreak Mod with Plugin API ( 90% ) Public
shuttle_wave is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-09-2010 , 03:00   Re: random msg
Reply With Quote #3

It's better to only have one task than have 32 tasks all doing the same thing.
__________________
fysiks is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 06-09-2010 , 03:04   Re: random msg
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
It's better to only have one task than have 32 tasks all doing the same thing.
my one or his version?
__________________
JailBreak Mod with Plugin API ( 90% ) Public
shuttle_wave is offline
FlyingHorse
Senior Member
Join Date: Apr 2010
Location: Under your bed.
Old 06-09-2010 , 08:28   Re: random msg
Reply With Quote #5

ehm.. i wanted help to fix my code. I would have posted in suggestions, requests if i wanted a new plugin .. Im a beginner and im still learning. In fact i started like 2 weeks ago. I'd like help, not a new plugin, could anyone just help me fix whats not working in my code?
FlyingHorse is offline
Send a message via Skype™ to FlyingHorse
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 06-09-2010 , 08:54   Re: random msg
Reply With Quote #6

Quote:
Originally Posted by shuttle_wave View Post
my one or his version?
Ur version, hes version is running a task for all players on the server. And hes not removing the task if players disconnect so that will probally get fucked up to.

I blame client_putinserver, try client_authorized or client_connect, else hook the Spawn event with ham.
__________________
I am out of order!
grimvh2 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-09-2010 , 12:47   Re: random msg
Reply With Quote #7

Quote:
Originally Posted by shuttle_wave View Post
my one or his version?
Your code does what I suggested already (you should know that ).

Quote:
Originally Posted by FlyingHorse View Post
ehm.. i wanted help to fix my code. I would have posted in suggestions, requests if i wanted a new plugin .. Im a beginner and im still learning. In fact i started like 2 weeks ago. I'd like help, not a new plugin, could anyone just help me fix whats not working in my code?
He didn't post a new plugin, he posted a plugin that shows you how to do it more efficiently. If you notice, his plugin will not do what you are trying to do.

Quote:
Originally Posted by grimvh2 View Post
I blame client_putinserver, try client_authorized or client_connect, else hook the Spawn event with ham.
I seriously doubt that is the problem. putinserver is probably one of the better ones to use.

@FlyingHorse, when you post code you can't just say "why doesn't this work," you need to explain what doesn't work about it. Does it compile? Does it have any errors? If it does compile and there are no errors you need to say that. This type of information will get you the best response.

Also, debugging is a skill everybody needs to learn. 1. It creates less posts here. 2. It will usually solve your problem much more promptly than waiting for people to respond to you post.

This is something that I would use:

PHP Code:
#include <amxmodx>
#include <colorchat>

new const szMessages[][] = {
    
"lol",
    
"blah",
    
"Drekes has a ponytail!",
    
"omfg"
}

public 
plugin_init()
{
    
// set_task()
}

public 
advertisements(id)
{
    
ColorChat(0REDszMessages[random(sizeof(szMessages))])
    
// Or loop through players if you want them to have different messages.

__________________

Last edited by fysiks; 06-09-2010 at 12:54.
fysiks is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-09-2010 , 14:40   Re: random msg
Reply With Quote #8

Why is my ponytail in there? I don't think it is usefull information to advertise.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 06-10-2010 , 12:25   Re: random msg
Reply With Quote #9

@fysiks, I know what I say. I make more private then public plugins and when testing those plugins I occur alot of problems with using tasks when people are connecting and I never use client_putinserver since it always gave problems.
__________________
I am out of order!
grimvh2 is offline
Brreaker
Senior Member
Join Date: Oct 2009
Location: Constanta, Romania
Old 06-10-2010 , 12:59   Re: random msg
Reply With Quote #10

Quote:
Originally Posted by grimvh2 View Post
@fysiks, I know what I say. I make more private then public plugins and when testing those plugins I occur alot of problems with using tasks when people are connecting and I never use client_putinserver since it always gave problems.
As far as I know ( I may be mistaking ):
client_putinserver = client starting to connect ( console connecting )
client_connected = client is on the server, ready to choose the team...
__________________
There are 10 kinds of people.Those who understand binary, and those who don't.
Also, for those who understand binary, there is a donation tab too!
No steam || PM support!
Brreaker is offline
Send a message via MSN to Brreaker Send a message via Yahoo to Brreaker
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 17:15.


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