Raised This Month: $ Target: $400
 0% 

What's wrong with this code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-30-2011 , 08:12   What's wrong with this code?
Reply With Quote #1

PHP Code:
public client_authorized(id)
{
 
set_task(60.0"PrintText" ,id)
}
public 
PrintText(id)
{
 
client_print(idprint_chat"[VIP] Write /wantvip and u will see VIP privilegies and hot to get VIP.")

It should write one time "[VIP] Write /wantvip and u will see VIP privilegies and hot to get VIP.", but sometimes it writes triple.

And why this code gives grenades every round and when new player joins server?
PHP Code:
public fwHamPlayerSpawnPost() {

    new 
players[32], playerpnum;
    
get_players(playerspnum"a");
    for(new 
0pnumi++)
    {
        
player players[i];
        if(
is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_I)
        {
        
give_item(player"weapon_hegrenade");
        
give_item(player"weapon_flashbang");
        
give_item(player"weapon_flashbang");
        
give_item(player"weapon_smokegrenade");
        
give_item(player"item_assaultsuit");
        
give_item(player"item_thighpack");
        }
    }
    return 
PLUGIN_HANDLED


Last edited by Evaldas.Grigas; 09-30-2011 at 08:17.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Jenkins
AlliedModders Donor
Join Date: Jul 2011
Old 09-30-2011 , 08:16   Re: What's wrong with this code?
Reply With Quote #2

try this:
Code:
public client_authorized(id)
{
 set_task(60.0, "PrintText")
}
public PrintText(id)
{
 client_print(id, print_chat, "[VIP] Write /wantvip and u will see VIP privilegies and hot to get VIP.")
}
if it doesnt work try using colorchat:
Code:
public client_authorized(id)
{
 set_task(60.0, "PrintText")
}
public PrintText(id)
{
 ColorChat(id, GREY, "[VIP] Write /wantvip and u will see VIP privileges and how to get the VIP."
}

Last edited by Jenkins; 09-30-2011 at 08:16. Reason: .
Jenkins is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-30-2011 , 08:20   Re: What's wrong with this code?
Reply With Quote #3

The first code you writed is the same as mine .
I am testing second right now.

P.S. Check main post.

Edit: Undefined symbol Color chat... What should I include?

Last edited by Evaldas.Grigas; 09-30-2011 at 08:25.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-30-2011 , 08:26   Re: What's wrong with this code?
Reply With Quote #4

using same task id for every player isnt gonna make it work better.
try using client_putinserver instead of client_authorized
PHP Code:
public client_putinserver(id)
{
 if (!
task_exists(id)) set_task(60.0"PrintText" ,id)
}
public 
PrintText(id)
{
 
client_print(idprint_chat"[VIP] Write /wantvip and u will see VIP privilegies and hot to get VIP.")

Quote:
And why this code gives grenades every round and when new player joins server?
because its coded to loop trough all players when one players spawns, and give items to players with ADMIN_LEVEL_I access

Last edited by jimaway; 09-30-2011 at 08:29.
jimaway is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-30-2011 , 08:28   Re: What's wrong with this code?
Reply With Quote #5

So it should be like this?
PHP Code:
public fwHamPlayerSpawnPost() {

        if(
is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_I)
        {
        
give_item(player"weapon_hegrenade");
        
give_item(player"weapon_flashbang");
        
give_item(player"weapon_flashbang");
        
give_item(player"weapon_smokegrenade");
        
give_item(player"item_assaultsuit");
        
give_item(player"item_thighpack");
        }
    return 
PLUGIN_HANDLED

Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-30-2011 , 08:29   Re: What's wrong with this code?
Reply With Quote #6

PHP Code:
public fwHamPlayerSpawnPost(player) {

        if(
is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_I)
        {
        
give_item(player"weapon_hegrenade");
        
give_item(player"weapon_flashbang");
        
give_item(player"weapon_flashbang");
        
give_item(player"weapon_smokegrenade");
        
give_item(player"item_assaultsuit");
        
give_item(player"item_thighpack");
        }

jimaway is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-30-2011 , 08:44   Re: What's wrong with this code?
Reply With Quote #7

No. It should be like this (am I right?):
PHP Code:
public fwHamPlayerSpawnPost(id) {

    if(
is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H)
    {
    
give_item(id"weapon_hegrenade");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_smokegrenade");
    
give_item(id"item_assaultsuit");
    
give_item(id"item_thighpack");
    }

It compiles no errors. Your compiles with errors.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
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:34.


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