AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What's wrong with this code? (https://forums.alliedmods.net/showthread.php?t=168511)

Evaldas.Grigas 09-30-2011 08:12

What's wrong with this code?
 
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



Jenkins 09-30-2011 08:16

Re: What's wrong with this code?
 
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."
}


Evaldas.Grigas 09-30-2011 08:20

Re: What's wrong with this code?
 
The first code you writed is the same as mine :D.
I am testing second right now.

P.S. Check main post.

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

jimaway 09-30-2011 08:26

Re: What's wrong with this code?
 
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

Evaldas.Grigas 09-30-2011 08:28

Re: What's wrong with this code?
 
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



jimaway 09-30-2011 08:29

Re: What's wrong with this code?
 
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");
        }



Evaldas.Grigas 09-30-2011 08:44

Re: What's wrong with this code?
 
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.


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

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