AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   make anything for CT only (https://forums.alliedmods.net/showthread.php?t=293301)

yas17sin 01-28-2017 14:07

make anything for CT only
 
Hi guys

i need to know how to restict something from Ts .

and make it for CTs only so Ts can't be able to pickup it or purchase it or any other thing.

but when Ts transfer to CTs he can get it then.

OciXCrom 01-28-2017 14:30

Re: make anything for CT only
 
https://www.amxmodx.org/api/cstrike/cs_get_user_team

yas17sin 01-28-2017 15:09

Re: make anything for CT only
 
i am just beginner at this stuff and i can't know directley from the examples you give me and also i don't have a good english please explain me more esasy.

EFFx 01-28-2017 16:30

Re: make anything for CT only
 
The API says all.

id = Player's ID
model = Player's team ( CS_TEAM_T, CS_TEAM_CT, CS_TEAM_SPECTATOR and CS_TEAM_UNASIGNED )

In your case, you should just use

PHP Code:

if(cs_get_user_team(playerid) == CS_TEAM_CT 

Try make what I'm doing aswell, searching API for learn how to do something. And if you doesn't find anything on the API related to what you're seaching for ( what's hard ), search that stuff here, most of them already exists or already someone are using him and you can copy it.

yas17sin 01-28-2017 19:00

Re: make anything for CT only
 
Quote:

Originally Posted by EFFx (Post 2490659)
The API says all.

id = Player's ID
model = Player's team ( CS_TEAM_T, CS_TEAM_CT, CS_TEAM_SPECTATOR and CS_TEAM_UNASIGNED )

In your case, you should just use

PHP Code:

if(cs_get_user_team(playerid) == CS_TEAM_CT 

Try make what I'm doing aswell, searching API for learn how to do something. And if you doesn't find anything on the API related to what you're seaching for ( what's hard ), search that stuff here, most of them already exists or already someone are using him and you can copy it.

Thanks EFFx for your usefull comment i appreciate your help. :oops:

edon1337 01-29-2017 16:26

Re: make anything for CT only
 
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T
         return;                                                     
/* Restrict Terrorists from using */

else 
         
//.. code ..//                                              /* What can CTs do with it */ 


yas17sin 01-29-2017 16:45

Re: make anything for CT only
 
Quote:

Originally Posted by edon1337 (Post 2490958)
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T
         return;                                                     
/* Restrict Terrorists from using */

else 
         
//.. code ..//                                              /* What can CTs do with it */ 


okay Tanks i understand how to do that :D .

addons_zz 01-29-2017 17:24

Re: make anything for CT only
 
Quote:

Originally Posted by edon1337 (Post 2490958)
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T
         return;                                                     
/* Restrict Terrorists from using */

else 
         
//.. code ..//                                              /* What can CTs do with it */ 


Dont do that. Despite it it will work, but there is no reason for the dangling `else` unbraced.

Do something like:
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T
{
    return;                                                     
/* Restrict Terrorists from using */
}
else 
{
    
//.. code ..//                                             /* What can CTs do with it */


or
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T
    return;                                                         
/* Restrict Terrorists from using */

//.. code ..//                                                      /* What can CTs do with it */ 

or
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T) return;                       /* Restrict Terrorists from using */

//.. code ..//                                                      /* What can CTs do with it */ 


yas17sin 01-29-2017 18:19

Re: make anything for CT only
 
Quote:

Originally Posted by edon1337 (Post 2490958)
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T) return;                       /* Restrict Terrorists from using */

//.. code ..//                                                       /* What can CTs do with it */ 


that's look more easy and simple. Thanks For making examples.

edon1337 01-30-2017 07:59

Re: make anything for CT only
 
Quote:

Originally Posted by addons_zz (Post 2490969)
Dont do that. Despite it it will work, but there is no reason for the dangling `else` unbraced.

Do something like:
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T
{
    return;                                                     
/* Restrict Terrorists from using */
}
else 
{
    
//.. code ..//                                             /* What can CTs do with it */


or
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T
    return;                                                         
/* Restrict Terrorists from using */

//.. code ..//                                                      /* What can CTs do with it */ 

or
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T) return;                       /* Restrict Terrorists from using */

//.. code ..//                                                      /* What can CTs do with it */ 


Braces weren't needed in this example.

@yas17in I don't suggest skipping 'else', you might mess up sometimes.


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

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