AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A little help. (https://forums.alliedmods.net/showthread.php?t=242027)

nixh 06-12-2014 16:36

A little help.
 
This message shows only for terrorists and its allright no need to change here anything.
PHP Code:

ShowSyncHudMsg(idhudhandler"Day: %d | Reason: %s"roundsreasons[userreason[id]]) 

But how to make that CT can see it too but with different text like this...
PHP Code:

ShowSyncHudMsg(idhudhandler"Day: %d"

Full code.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Jail Break: Basic Info"
#define VERSION "1.0"
#define AUTHOR "Sn!ff3r"

#define USERTASK 921
#define UPDATEDELAY 1.0

new static reasons[][] = {
"1.",
"2.",
"3.",
"4.",
"5.",
"6.",
"7.",
"8."
}

new 
userreason[33]
new 
roundshudhandler

public plugin_init()
{
register_plugin(PLUGINVERSIONAUTHOR)

register_event("TextMsg","restart_roundsnum""a","2&#Game_C"/*,"2&#Game_w"*/)

register_logevent("round_end"2"1=Round_End")

RegisterHam(Ham_Spawn"player""client_spawn"1)

hudhandler CreateHudSyncObj()
}

public 
round_end()
{
rounds ++
}

public 
restart_roundsnum()
{
rounds 0
}

public 
client_disconnect(id)
{
userreason[id] = -1

if(task_exists(id USERTASK))
{
remove_task(id USERTASK)
}
}

public 
client_spawn(id)
{
if(
task_exists(id USERTASK))
{
remove_task(id USERTASK)
}

if(
get_user_team(id) == 1)
{
userreason[id] = random_num(0sizeof reasons 1)

set_task(UPDATEDELAY"client_jailinfo"id USERTASK__"b")
}
}

public 
client_jailinfo(TASKID)
{
static 
id
id 
TASKID USERTASK

set_hudmessage
(025500.80.106.012.0)

ShowSyncHudMsg(idhudhandler"Day: %d | Reason: %s"roundsreasons[userreason[id]])


EDIT: Flick3rR, a thanks man i really appreciate it and you to bat. :)

bat 06-12-2014 16:47

Re: A little help.
 
Try...
Code:

if(cs_get_user_team(id) == CS_TEAM_T)
{
  ShowSyncHudMsg(id, hudhandler, "Day: %d | Reason: %s", rounds, reasons[userreason[id]])
}
else
{
  ShowSyncHudMsg(id, hudhandler, "Day: %d")
}


Flick3rR 06-12-2014 16:50

Re: A little help.
 
First you have to remove the check for the team before setting the task. In other word:
PHP Code:

public client_spawn(id)
{
if(
task_exists(id USERTASK))
{
remove_task(id USERTASK)
}

if(
get_user_team(id) == 1)
{
userreason[id] = random_num(0sizeof reasons 1)

set_task(UPDATEDELAY"client_jailinfo"id USERTASK__"b")
}


Should look like this:
PHP Code:

public client_spawn(id)
{
    if(
task_exists(id USERTASK))
    {
        
remove_task(id USERTASK)
    }
    
    
userreason[id] = random_num(0sizeof reasons 1)
    
    
set_task(UPDATEDELAY"client_jailinfo"id USERTASK__"b")
    


Then we put a check and format the message depending on user's team in the task itself. There are two ways to do what you want, on my mind.

1)
PHP Code:

public client_jailinfo(TASKID)
{
    static 
id
    id 
TASKID USERTASK

    set_hudmessage
(025500.80.106.012.0)

    new 
message[64]
    switch(
get_user_team(id))
    {
        case 
1formatex(messagecharsmax(message), "Day: %d | Reason: %s"roundsreasons[userreason[id]])
        case 
2formatex(messagecharsmax(message), "Day: %d"rounds)
    }
    
ShowSyncHudMsg(idhudhandlermessage)


2)
PHP Code:

public client_jailinfo(TASKID)
{
    static 
id
    id 
TASKID USERTASK

    set_hudmessage
(025500.80.106.012.0)

    new 
message[64]
    
formatex(messagecharsmax(message),"  | Reason: %s"reasons[userreason[id]])
    
ShowSyncHudMsg(idhudhandler"Day: %d%s"roundsget_user_team(id) == message "")



wickedd 06-12-2014 18:23

Re: A little help.
 
@nixh
Don't delete or edit your original post once you solve your problem.


All times are GMT -4. The time now is 21:10.

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