AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Using prethink.. need some help! (https://forums.alliedmods.net/showthread.php?t=96122)

HLM 06-30-2009 21:42

Using prethink.. need some help!
 
okay.. ive been working on a plugin.. tried doing it with the knowledge of PAST HANDWALKING ONLY!

it failed :cry: :cry: so now, im here again.. please, someone tell me wich way to go please..

PHP Code:

/* Script generated by Pawn Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <tfcx>
#include <engine>

#define PLUGIN    "Spy Cloak"
#define AUTHOR    "HLM"
#define VERSION    "0.5 Beta"

new float:lasttime[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
}
public 
client_PreThink(id)
{
    
    while (
lasttime[id] < get_systime) do lasttime[id] = get_systime 3
    
    
    
new name[33]
    
get_user_name(id,name,32)
    
    
    
log_amx("loaded ham_spy_cloak for %s",name)
    
    new class = 
entity_get_int(idEV_INT_playerclass)
    
log_amx("%s is class %i",name,class)
    
    if(class == 
8)        
    {
        
log_amx("does class == 8?")
        
        
set_user_rendering(id,kRenderFxNone,_,_,_,kRenderTransAlpha,128)
        
log_amx("%s was cloaked!",name)
        
client_print(id,print_chat,"%s, as a spy you have a visibility cloak!",name)
        
        new 
weapon get_user_weapon(id)
        if(
weapon == TFC_WPN_KNIFE)
        {
            
set_user_rendering(id,kRenderFxFlickerSlow,_,_,_,kRenderTransAlpha,85)
            
log_amx("%s is holding a knife!",name)
            
client_print(id,print_chat,"[AMXX] %s, The knife is making the cloak work better!",name)
        }
    }
    
log_amx("ham_spy_cloaked done loading for %s...",name)
    return 
PLUGIN_HANDLED


Code:

//// SpyCloak.sma
// C:\Program Files\AMX Mod X\files\base\scripting\SpyCloak.sma(22) : error 076:
 syntax error in the expression, or invalid function call
// C:\Program Files\AMX Mod X\files\base\scripting\SpyCloak.sma(22) : error 076:
 syntax error in the expression, or invalid function call
// C:\Program Files\AMX Mod X\files\base\scripting\SpyCloak.sma(22 -- 25) : warn
ing 213: tag mismatch
// C:\Program Files\AMX Mod X\files\base\scripting\SpyCloak.sma(25) : error 001:
 expected token: "while", but found "new"
// C:\Program Files\AMX Mod X\files\base\scripting\SpyCloak.sma(25) : fatal erro
r 107: too many error messages on one line


TheRadiance 07-01-2009 06:23

Re: Using prethink.. need some help!
 
PHP Code:

/* Script generated by Pawn Studio */

#include <amxmodx>
//#include <amxmisc> amxmisc is not necessary here;
#include <fun>
#include <tfcx>
#include <engine>

#define PLUGIN    "Spy Cloak"
#define AUTHOR    "HLM"
#define VERSION    "0.5 Beta"

//new float:lasttime[33] - float is not correct data type in pawn - there is Float;
new Float:lasttime[33// correct;

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
}
public 
client_PreThink(id)
{
    
//    while (lasttime[id] < get_systime) do lasttime[id] = get_systime + 3 - incorrect usage;
    /* do - while usage:
    * "do" - action;
    * "while" - condition;
    * "do* - type of loop where an action will be executed at least once (in "do")
    * because of this "while" must go after "do"
    */

    //also get_systime is a function from amxmodx.inc and it must be with parentheses ();

    // correct usage of do - while:
    
do
    {
        
lasttime[id] = get_systime() + 3.0 // 3.0 because of lasttime type is Float;
    
}
    
    while (
lasttime[id] < get_systime())

    
// part of script below is normal;

    
new name[33]
    
get_user_name(id,name,32)
    
    
    
log_amx("loaded ham_spy_cloak for %s",name)
    
    new class = 
entity_get_int(idEV_INT_playerclass)
    
log_amx("%s is class %i",name,class)
    
    if(class == 
8)        
    {
        
log_amx("does class == 8?")
        
        
set_user_rendering(id,kRenderFxNone,_,_,_,kRenderTransAlpha,128)
        
log_amx("%s was cloaked!",name)
        
client_print(id,print_chat,"%s, as a spy you have a visibility cloak!",name)
        
        new 
weapon get_user_weapon(id)
        if(
weapon == TFC_WPN_KNIFE)
        {
            
set_user_rendering(id,kRenderFxFlickerSlow,_,_,_,kRenderTransAlpha,85)
            
log_amx("%s is holding a knife!",name)
            
client_print(id,print_chat,"[AMXX] %s, The knife is making the cloak work better!",name)
        }
    }
    
log_amx("ham_spy_cloaked done loading for %s...",name)
    return 
PLUGIN_HANDLED



HLM 07-01-2009 16:47

Re: Using prethink.. need some help!
 
thanks TheRadiance. I now realize once I do something, I need to stick to it! now, I need to hook some curweapon events...

Bugsy 07-01-2009 22:43

Re: Using prethink.. need some help!
 
Explain what you are attempting to do, there may be a better and more resourceful way.

HLM 07-02-2009 00:48

Re: Using prethink.. need some help!
 
I was trying to do exactly what is above.. make a spy cloak.. so when a users class is 'tfc_pc_spy' he will be partially cloaked, and if the user is also using knife, the use gets an advanced cloak, but I have solved this by hooking the Curweapon event and ham_spawn to a set_task.. its working fine right now, thank you though :)

Bugsy 07-02-2009 08:54

Re: Using prethink.. need some help!
 
Are you still using prethink?

HLM 07-02-2009 16:33

Re: Using prethink.. need some help!
 
nope, hooked it all into a set_task of 6.0 seconds after user spawns, and hooked CurWeapon, my current problem is with hooking Feign...
Code:

Game registered user msgs:    msgid  size
Feign                      114      1

this is the code I have for it..
plugin_init
PHP Code:

register_event("Feign","feigned","be","1=1"

PHP Code:

public feigned(id)
{
    
log_amx("stated logging for feigned index")
    if(
get_pcvar_num(g_spycloak))
    {
        new class = 
entity_get_int(idEV_INT_playerclass)
        
log_amx("got playerclass %i",class)
        new 
name[33]
        
get_user_name(id,name,32)
        
log_amx("got player name of %s",name)
        if(class == 
8)
        {
            
log_amx("%s is a spy.. in feigned index..",name)
            
set_user_rendering(id,kRenderFxNone,_,_,_,kRenderTransAlpha,0)
            
log_amx("%s is feigning with full cloak",name)
            
client_print(id,print_chat"[AMXX] SpyCloak has detected you're feigning death, you are completely invisible now!")
        }
    }
    return 
PLUGIN_CONTINUE


with the log events there, I can tell that it is never called..

Xellath 07-02-2009 16:35

Re: Using prethink.. need some help!
 
What event is "Feign"?

Bugsy 07-02-2009 16:53

Re: Using prethink.. need some help!
 
You have these events to choose from, you can't make up your own:

http://wiki.amxmodx.org/Half-Life_1_Game_Events

HLM 07-02-2009 19:26

Re: Using prethink.. need some help!
 
no! its a game message for tfc... I thought it was enough proof showing an output from meta game... feign is an action a TFC SPY can do...

Code:

20:09:24 meta game
20:09:24 GameDLL info:
                name: tfc
                desc: NeoTF_i486.so (override)
              gamedir: /usr/local/games/tfc/734898/68.232.163.97:27015/tfc
            dll file: NeoTF_i486.so
        dll pathname: /usr/local/games/tfc/734898/68.232.163.97:27015/tfc/addons/NeoTF/dlls/NeoTF_i486.so
        Game registered user msgs:    msgid  size
            VoiceMask                    64      8
            ReqState                    65      0
            SelAmmo                      66      4
            CurWeapon                    67      3
            Geiger                      68      1
            Flashlight                  69      2
            FlashBat                    70      1
            Health                      71      1
            Damage                      72    12
            Battery                      73      4
            SecAmmoVal                  74      2
            SecAmmoIcon                  75    -1
            Train                        76      1
            Items                        77      4
            Concuss                      78      1
            HudText                      79    -1
            SayText                      80    -1
            StatusIcon                  81    -1
            TextMsg                      82    -1
            SpecHealth                  83      1
            StatusText                  84    -1
            StatusValue                  85      3
            WeaponList                  86    -1
            ResetHUD                    87      1
            InitHUD                      88      0
            ViewMode                    89      0
            GameTitle                    90      1
            DeathMsg                    91    -1
            ScoreInfo                    92      9
            TeamInfo                    93    -1
            TeamScore                    94    -1
            GameMode                    95      1
            MOTD                        96    -1
            ServerName                  97    -1
            AmmoPickup                  98      2
            WeapPickup                  99      1
            ItemPickup                  100    -1
            HideWeapon                  101      1
            SetFOV                      102      1
            ShowMenu                    103    -1
            ScreenShake                104      6
            ScreenFade                  105    10
            AmmoX                      106      2
            Bench                      107      1
            Spectator                  108      2
            AllowSpec                  109      1
            SpecFade                    110      6
            ResetFade                  111      0
            ValClass                    112    10
            TeamNames                  113    -1
            Feign                      114      1
            Detpack                    115      1
            VGUIMenu                    116    -1
            BuildSt                    117      2
            RandomPC                    118      1
            HudTextPro                  119    -1
        56 game user msgs

are you saying all of these arent legit?

edit: if I set the regevent to take out the 1=1 or turn it to 1=0 it gives me the message for about a millisecond..

EDIT: is there a way to tell when an event ='s something?
for example: event 'Feign' changed to 1...


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

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