AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   some noob-questions (https://forums.alliedmods.net/showthread.php?t=184313)

simple_user 05-03-2012 16:43

some noob-questions
 
1) what does this mean? :
if (!killer || !victim) // ! in front of id ?

for example, I know that:
if ( killer != gSuperPlayerCT || killer != gSuperPlayerT ) // means if a is not equal to b or a isn't equal to c

2) and what is the differences between these:

public (weaponId)

if(weaponId == CSW_KNIFE)
{
do...
}


and this:

new weapon = get_user_weapon(id);

if(weapon == CSW_KNIFE)

{
do...

}

rak 05-03-2012 17:04

Re: some noob-questions
 
PHP Code:

if (!killer || !victim// ! in front of id ? 

:arrow:
PHP Code:

if (killer == || victim == 0

---

means if a is not equal to b or a isn't equal to c

if i understand you... yes..

-------------

public PUBLIC_NAME(weaponId)

if(weaponId == CSW_KNIFE)
{
do...
}

this is a public function with the param weapoinId

and the second you obten the weaponid;

example

PHP Code:

new weapon get_user_weapon(id); 

if(
weapon == CSW_KNIFE

do... 
}

// or i can do this...

new weapon get_user_weapon(id); 

my_function(weapon)

}

public 
my_function(WeaponId)
{
 
if(
WeaponId == CSW_KNIFE

do... 
}




Exolent[jNr] 05-03-2012 17:09

Re: some noob-questions
 
Quote:

Originally Posted by rak (Post 1701425)
PHP Code:

if (!killer || !victim// ! in front of id ? 

:arrow:
PHP Code:

if (killer <= || victim <= 0


That's wrong. ! means not. In this case, it means if not value, meaning if there is no value.
For there to be no value, it would have to have 0.

Here's an example:
Code:
new var1 = 200; new var2 = -10; new var3 = 0; if(var1) // true if(var2) // true if(var3) // false // !var1 = not 200 = 0 // !var2 = not -10 = 0 // !var3 = not 0 = 1 if(!var1) // false if(!var2) // false if(!var3) // true

rak 05-03-2012 17:26

Re: some noob-questions
 
Quote:

Originally Posted by Exolent[jNr] (Post 1701431)
That's wrong. ! means not. In this case, it means if not value, meaning if there is no value.
For there to be no value, it would have to have 0.

yes, my mistake; sorry xD i don't sleep u.u; i don't know what I think xD

rak 05-03-2012 17:29

Re: some noob-questions
 
Quote:

Originally Posted by simple_user (Post 1701450)
So basically:

if(!killer || !victim) // means if there is a killer or victim
return;
{
client_print(victim, print_chat, "A person killed you, not the sunstroke
.")
}


?

nope;

and use [php][/php] for code

is
PHP Code:

{
if(!
killer || !victim)// means if there is a killer or victim
            
return;
client_print(victimprint_chat"A person killed you, not the sunstroke.")



simple_user 05-03-2012 18:09

Re: some noob-questions
 
PHP Code:

you knowI don't believe you, because you said something about your sleep ^ ^ 


fysiks 05-04-2012 03:39

Re: some noob-questions
 
Quote:

Originally Posted by simple_user (Post 1701450)
So basically:

PHP Code:

if(!killer || !victim//  if no killer or victim, return value 0. if there is a killer or victim then do something
return;
    {
       
client_print(victimprint_chat"A person killed you, not the sunstroke[/I][I].")
    } 

?

That code doesn't make sense anyways.

The if condition will be true if either there is no killer or there is no victim (which doesn't make sense).

simple_user 05-04-2012 08:29

Re: some noob-questions
 
I found it in ut_killstreak_adv plugin. This looked unusual to me, so I was wondering.
Here's the context:

PHP Code:

public client_death(killer,victim,weapon,hitplace,TK)
{
    if(!
killer || !victim)
        return;
    
    static 
kname[32], vname[32];
    
get_user_name(killer,kname,31);
    
get_user_name(victim,vname,31);
    
    if(
hitplace == HIT_HEAD && get_pcvar_num(hsenable) == )
    {
        
set_hudmessage(00255, -1.00.3006.06.0);
        
show_hudmessage(0hsmessages[random(sizeof hsmessages)], knamevname);
        
client_cmd(0,"spk %s",hslist[random(sizeof hslist)]);
    }
    
    if(
weapon == CSW_KNIFE && get_pcvar_num(knifeenable) == )
    {
        
set_hudmessage(2550255, -1.00.3006.06.0);
        
show_hudmessage(0knmessages[random(sizeof knmessages)], knamevname);
        
client_cmd(0,"spk %s",knlist[random(sizeof knlist)]);   
    } 


claudiuhks 05-04-2012 08:54

Re: some noob-questions
 
Operator ! means is not
Operator != means is not equal with
Operator == means is equal with

PHP Code:

static i;
0;

if( !
) { /* do this */ // i is 0

static c];
c] = '';

if( !
c] ) { /* do this */ // c[ 0 ] is ''

"";

if( !
c] ) { /* do this */ // c[ 0 ] is '' 


Quote:

Originally Posted by rak (Post 1701425)
PHP Code:

if (!killer || !victim// ! in front of id ? 

:arrow:
PHP Code:

if (killer <= || victim <= 0


Please edit.

simple_user 05-04-2012 14:58

Re: some noob-questions
 
Another question. Is it right to pause an entire plugin in game, by hooking some event and then unpause the same way?
Example: Pause respawn.amxx when bomb is planted, and unpause on new round.


All times are GMT -4. The time now is 00:25.

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