AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Thunder, need good code. (https://forums.alliedmods.net/showthread.php?t=140223)

Screeaam.. 10-09-2010 18:58

Thunder, need good code.
 
Hello everyone. I have problem with one, small code... I need to make an thunder... If player tap button "E (+use)" on Knife and his crossair will be on the enemy in little area in enemy will hit thunder which takin about 80 dmg. And the cooldown of thunder will be 10 sec. This's my code:


Code:

public MakeThunderBolt(id)
{
        if (halflife_time()-gravitytimer[id] <= 10)
        {
                hudmsg(id,2.0,"Thunder can be used in 10 seconds.",gravitytimer[id])
                return PLUGIN_CONTINUE
        }
   
        gravitytimer[id] = floatround(halflife_time())
       
        new iMakerOrigin[3], Float:iMakeOriginSe[3];
        get_user_origin(id, iMakerOrigin);
        for(new i = 0; i < 3; i++){
                iMakeOriginSe[i] = float(iMakerOrigin[i]);
        }
       
        new entPlayer;
        entPlayer = -1;
       
        while((entPlayer = find_ent_in_sphere(id, iMakeOriginSe, 550.0)) != 0)
        {
                new iVictimOrigin[3];
                get_user_origin(entPlayer, iVictimOrigin);
                change_health(entPlayer, -80, 0, "world");
                CreateBolt(entPlayer, iMakerOrigin, iVictimOrigin);
                g_thunderbolt[id]++;
        }
        return PLUGIN_CONTINUE;
}

CreateBolt(iPlayer, iMaker[3], iVictim[3]) {
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(0)
        write_coord(iMaker[0])
        write_coord(iMaker[1])
        write_coord(iMaker[2])
        write_coord(iVictim[0])
        write_coord(iVictim[1])
        write_coord(iVictim[2])
        write_short(light)
        write_byte(1)
        write_byte(5)
        write_byte(2)
        write_byte(20)
        write_byte(30)
        write_byte(255)
        write_byte(255)
        write_byte(255)
        write_byte(200)
        write_byte(200)
        message_end()
}

PreThink:

Code:

        if (button2 & IN_USE && on_knife[id] && button[id]==0 && piorunek[id]==1){
                  button[id] = 1;
                  MakeThunderBolt(id)
        }

Is it good code? Cause' I can't test it, I haven't server yet. Or gimme good code for it.

It's code for DiabloMod 5.9l SQL.

And sorry for my english.

SaM.ThE.MaN 10-09-2010 19:02

Re: Thunder, need good code.
 
test it on ur Counter strike , install Amxmodx on your cs and add your plugin , then new game

Screeaam.. 10-09-2010 19:03

Re: Thunder, need good code.
 
Can't test now. I go sleep in 5 minutes, it's 1 a.m. ;/

Can someone tell on first look is it good?

fysiks 10-09-2010 20:44

Re: Thunder, need good code.
 
Quote:

Originally Posted by Screeaam.. (Post 1320641)
Can't test now. I go sleep in 5 minutes, it's 1 a.m. ;/

Can someone tell on first look is it good?

Yep, I will tell you. It won't work. Why? Because there is not a complete plugin in that code.

Screeaam.. 10-10-2010 05:22

Re: Thunder, need good code.
 
So, what is need to be in it to complete it? (it's cut from Diablo)

I know, I don't wrote there variable's it's

new piorunek[33];

And remember, it's code to DiabloMod.

Someone can write good code?

Screeaam.. 10-10-2010 14:07

Re: Thunder, need good code.
 
Can someone give good code? :<

@edit:

New code:

Code:

public item_piorun(id)
{
        if (halflife_time()-gravitytimer[id] <= 10)
        {
                  hudmsg(id,2.0,"Thunder can be used in 10 seconds.")
                  return PLUGIN_CONTINUE
        }
    gravitytimer[id] = floatround(halflife_time())
   
    new targetplayer = UTIL_FindNearestOpponent(id,600)
   
    if (targetplayer == -1)
        return PLUGIN_HANDLED
   
    new damage = 80+player_intelligence[id]/2
    new Hit2[3]
    get_user_origin(targetplayer, Hit2)
   
    hudmsg(id, 2.0, "You hit %i dmg", damage)

    change_health(targetplayer,-damage,0,"world")
    CreateBolt(Hit2)

    return PLUGIN_CONTINUE;
}

CreateBolt(Hit2[3]) {
        message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
        write_byte( 0 )
        write_coord( Hit2[ 0 ] )
        write_coord( Hit2[ 1 ] )
        write_coord( Hit2[ 2 ] + 200)
        write_coord( Hit2[ 0 ] )
        write_coord( Hit2[ 1 ] )
        write_coord( Hit2[ 2 ] )
        write_short( light )
        write_byte( 1 )
        write_byte( 5 )
        write_byte( 2 )
        write_byte( 20 )
        write_byte( 30 )
        write_byte( 255 )
        write_byte( 255 )
        write_byte( 255 )
        write_byte( 200 )
        write_byte( 200 )
        message_end( )
}

All is good, but I can use it only once... I need to use it in 10 seconds... How can I make it?


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

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