AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Models and Set_task Help (https://forums.alliedmods.net/showthread.php?t=309671)

RockyRock123 08-03-2018 09:23

Models and Set_task Help
 
Just Started this Scripting thing about a month ago
And as I was Working on Jbextreme Plugin I found a bug in it
that if we change models of Simon Guard or Prisoner which are not complied in one File
Players Can Change the player Models
For e.g.
if i am prisoner I writes in console "model SIMON" it will change into Simon Model

*************
I was planning to fix it by set_task COMMAND but cant figure out how will it work

the code i wrote it given below
******
PHP Code:

public plugin_init()
{
    
set_task(5.0"Model_check"0__"b")
}
public 
Model_check(id)
{
        if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
        if(
user_Simon [id])
        {
            
cs_set_user_model(id"Simon")
        }
        else if(
Zombie_Day)
        {
            
cs_set_user_model(id"zombie")
        }
        else
        {
            
cs_set_user_model(id"guard")
        }
        }
        if(
cs_get_user_team(id) == CS_TEAM_T)
        {
            
cs_set_user_model(id"prisoners")
        }
            



Ghosted 08-03-2018 10:06

Re: Models and Set_task Help
 
Notice: set_task's 3rd param is equal to task's function first param 'public Model_check(id << this)', so if u set this 3rd param to 0, id will be 0

RockyRock123 08-03-2018 10:11

Re: Models and Set_task Help
 
A little More Explanation Plz.
:\
btw there are Many other set_tasks too
but
PHP Code:

#define TASK_MODEL 248600
public plugin_init()
{
set_task(5.0"Model_check"id+TASK_MODEL__"b")


as Cant Define id in plugin_init
so I tried it like this
PHP Code:

public Model_check(id)
{
set_task(7.0"Model_check"id+TASK_MODELCHECK__"b"
        if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
        if(
user_Simon [id])
        {
            
cs_set_user_model(id"Simon")
        }
        else if(
Zombie_Day)
        {
            
cs_set_user_model(id"zombie")
        }
        else
        {
            
cs_set_user_model(id"guard")
        }
        }
        if(
cs_get_user_team(id) == CS_TEAM_T)
        {
            
cs_set_user_model(id"prisoners")
        }
            


but it also didnt work

Ghosted 08-03-2018 11:47

Re: Models and Set_task Help
 
Yes you cant define id in plugin init. [remember] id is just name of that variable. you cant get player id variable, cause plugin_init is not for that. Forwards from where you can get player ids can be
client_connect(id)
client_putinserver(id)
client_disconnect(id)
client_disconnected(id)
Others done by hooking...


All times are GMT -4. The time now is 12:33.

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