UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Flashlight not working...

broken avatar :(
Created 12 years ago
by Deleted User
0 Members and 1 Guest are viewing this topic.
2,047 views
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Basically I scripted a flashlight script, but for some strange reason it doesn't work.
Code Snippet
Plaintext
#include clientscripts\_utility;
#include clientscripts\_vehicle;
#include clientscripts\_lights;
#include clientscripts\_fx;
#include clientscripts\_music;
precache()
{
level._effect["flashlight_fx"] = loadFX("fx/custom/flashlight");

}

main()
{
waitforclient(0);
realwait(1);
players = GetPlayers();
for(i = 0; i<players.size;i++){
players[i] thread player_flashlight(i);
}
}

player_flashlight(localclientnum)
{
for(;;)
{
fx = level._effect["flashlight_fx"];
currentweapon = GetCurrentWeapon(localclientnum);

if( ( currentweapon == "zombie_colt" || currentweapon == "zombie_colt_upgraded" || currentweapon = "zombie_g36c" || currentweapon = "zombie_g36c_upgraded") && !IsThrowingGrenade(localclientnum))
{
PlayViewmodelFx(localclientnum, fx, "tag_light");
}

realwait(0.1);
}
}
The FX is included and the main() function is called after precache(). Precache() is called before any threads. NOTE that this is a clientscript.
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 3 years ago
Posts
5,544
Respect
6,646Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Signature
If Java had true garbage collection, most programs would delete themselves upon execution.
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
For clientscripts you need to precache your fx in both GSC and CSC. If you were running with developer and developer_script you would have gotten an error which told you this.

If that doesn't fix it then you need to make sure your CSC is getting called by adding an iPrintLnBold in the for( ;; ). And you don't need a precache() function in CSC - clientscripts only run once the server is initialized which means you can't run any code from CSC before the level starts. You can declare a FX anywhere in your script as long as it was precached in GSC.

If you need a place to call your CSC from, I usually use _load::main().
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Fixed, apparently the problem was incorrect fx directory.
Gave you best answer though :)

 
Loading ...