AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to remember value? (https://forums.alliedmods.net/showthread.php?t=222856)

Randomize 08-07-2013 10:11

How to remember value?
 
I have trouble when remember value. I want to remember first value when I killed someone, and when I kill again, the first value moves to the third value. The problem is after killing player, the first value replaced not moved to the second, how was it?

PHP Code:

public dead(id)
{
    new 
killervictimhstargawpnid
    killer 
read_data(1)
    
victim read_data(2)
    
hs read_data(3)
    
wpnid get_user_weapon(killer)
    
    
chain_stopper kills[victim]
    
    new 
Float:timeleft get_gametime()-timekill[killer]
    if (
timeleft <= 9999kills[killer] += 1
    
else kills[killer] = 1
    
if (kills[killer])
    
timekill[killer] = get_gametime()

    if (!
piercing_shot[killer]) piercing_shot[killer] = 1
    
if (!timeleftpiercing_shot[killer] += 1
    
else piercing_shot[killer] = 1
    piercing_shot
[killer] = min(3piercing_shot[killer])
    
    if (
kills[killer])
    {
        
targa 1
    
}
    
// piercing shot
    
if (piercing_shot[killer] == 2)
    {
        
kills[killer] = kills[killer] - 1
        targa 
2
    
}
    else if (
piercing_shot[killer] == 3)
    {
        
kills[killer] = kills[killer] - 2
        targa 
3
    
}
    else if (
piercing_shot[killer] == 4)
    {
        
kills[killer] = kills[killer] - 3
        targa 
4
    
}
    if (
wpnid == CSW_KNIFE)
    {
        
// knife kill
        
targa 5
    
}
    if (
chain_stopper >= 4)
    {
        
// chain stopper
        
targa 6
    
}
    if (
hs)
    {
        
// hs
        
targa 7
    
}
    if (
hs && (wpnid == CSW_KNIFE))
    {
        
// hs with knife
        
targa 8
    
}
    if (
chain_stopper >= && (wpnid == CSW_KNIFE))
    {
        
// chain stopper & HS
        
targa 9
    
}
    if (
chain_stopper >= && hs)
    {
        
// chain stopper & HS
        
targa 10
    
}
    if (
chain_stopper >= && hs && (wpnid == CSW_KNIFE))
    {
        
// chain stopper & HS
        
targa 11
    
}
    
    
client_print(idprint_chat"%i"targa)
    
    
    new 
frag1[32], frag2[32], frag3[32], frag4[32], frag5[32], frag6[32], frag7[32], frag8[32], frag9[32]
    
    new 
firstsecondthirdfourthfifthsixthseventheighthninth
    
    
if (!first)  // this part, first until ninth
        
first targa
    
if (kills[killer] == 2)
        
second first
    
if (kills[killer] == 3)
        
third second
    
if (kills[killer] == 4)
        
fourth third
    
if (kills[killer] == 5)
        
fifth fourth
    
if (kills[killer] == 6)
        
sixth fifth
    
if (kills[killer] == 7)
        
seventh sixth
    
if (kills[killer] == 8)
        
eighth seventh
    
if (kills[killer] == 9)
        
ninth eighth




joropito 08-07-2013 14:34

Re: How to remember value?
 
You mean in subsequent calls to same function?

Use static

red_bull2oo6 08-07-2013 18:34

Re: How to remember value?
 
Quote:

Originally Posted by LordOfNothing (Post 2007798)
nvault

don't post such stupid answers.. he wants to only know it in that function.. not to load/save it.

@randomize: you should clear a bit your code.. and then you will figure it out.
you could also use something like:

Code:

new iKills[ 9 ]; // this is global one

if( !iKills[ 0 ] )
    iKills[ 0 ] = karga;
   
for( new i = 8; i >1; i-- )
    iKills[ i ] = iKills[ i -1 ];


Randomize 08-07-2013 23:27

Re: How to remember value?
 
Okay I will try.


All times are GMT -4. The time now is 15:57.

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