Raised This Month: $ Target: $400
 0% 

why this plugin make me crash ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Miew
Member
Join Date: Jan 2014
Old 04-25-2014 , 06:22   why this plugin make me crash ?
Reply With Quote #1

PHP Code:
#include <sourcemod>
#include <sdktools>

new Float:f_PosClient[3];

new 
g_HaloIndex;
new 
g_ModelIndex;

public 
Plugin:myinfo =
{
    
name "Player_Jump_Effect",
    
author "Skuzy",
    
description " ",
    
version "1.0.0",
    
url " "
};

public 
OnPluginStart()
{
    
HookEvent("player_jump"OnPlayerJump_CB);

    
g_HaloIndex PrecacheModel("materials/sprites/halo01.vmt");
    
g_ModelIndex PrecacheModel("sprites/laser.vmt");

}

public 
OnPlayerJump_CB(Handle:event, const String:name[], bool:dontBroadcast

    new 
userid GetEventInt(event"userid"); 
    new 
client GetClientOfUserId(userid);
        
Beam(client);


public 
Beam(client)
{
    
GetClientAbsOrigin(clientf_PosClient);

    
f_PosClient[2] += 5;
    new 
color[4];
    
color[0] = GetRandomInt(0255);
    
color[1] = GetRandomInt(0255);
    
color[2] = GetRandomInt(0255);
    
color[3] = 255;

    
TE_SetupBeamRingPoint(f_PosClient40.050.0g_ModelIndexg_HaloIndex0100.610.00.5color101);
    
TE_SendToAll();

Miew is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-25-2014 , 08:17   Re: why this plugin make me crash ?
Reply With Quote #2

which game and are you sure your gamedata files are up to date ?
Bacardi is online now
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 04-25-2014 , 08:19   Re: why this plugin make me crash ?
Reply With Quote #3

You need to add "materials/" in front of "sprites/" for your g_ModelIndex precache. Additionally (although this won't crash at first) things should be precached OnMapStart instead of OnPluginStart, because the precaches are cleared each time the map changes or reloads.

Also, you're adding an integer onto a float, which can never ever be a good thing, since the two are entirely different (as far as the plugin knows without conversion). Change f_PosClient[2] += 5; to f_PosClient[2] += 5.0;

Speaking of f_PosClient, there's no need to make it global if you're only going to use it in Beam(). Move new Float:f_PosClient[3]; to the top of Beam().

gosh dangit people keep replying just before i do today
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 04-25-2014 at 08:20.
MasterOfTheXP is offline
kNowo
Senior Member
Join Date: Apr 2011
Location: Malaysia
Old 04-25-2014 , 08:32   Re: why this plugin make me crash ?
Reply With Quote #4

Try updating your soul?
kNowo is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 04-25-2014 , 08:37   Re: why this plugin make me crash ?
Reply With Quote #5

Quote:
Originally Posted by kNowo View Post
Try updating your soul?
Now this post just made me confused
__________________
...
Oshizu is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 04-25-2014 , 09:10   Re: why this plugin make me crash ?
Reply With Quote #6

Make sure you have a proper check of client index.. make sure it Bigger than zero and in game.. thought it only spit lot of error without crashin but its a good practice.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 04-25-2014 , 10:37   Re: why this plugin make me crash ?
Reply With Quote #7

Typically, events will never have info like userid missing, and the user in question should always be valid. If you still want to check, just "if (!client) return;" should suffice, because if a userid is specified, but the userid is no longer in use, then GetClientOfUserId will simply return zero.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 04-27-2014 , 06:14   Re: why this plugin make me crash ?
Reply With Quote #8

I think you need to precache models in OnMapStart rather than OnPluginStart.
blaacky is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 04-27-2014 , 07:14   Re: why this plugin make me crash ?
Reply With Quote #9

Quote:
Originally Posted by blaacky View Post
I think you need to precache models in OnMapStart rather than OnPluginStart.
Precaching stuff on OnPluginStart might work, but it will be unprecached after map changes
So it's only one use trip
__________________
...
Oshizu is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 04-28-2014 , 01:01   Re: why this plugin make me crash ?
Reply With Quote #10

Quote:
Originally Posted by Oshizu View Post
Precaching stuff on OnPluginStart might work, but it will be unprecached after map changes
So it's only one use trip
Sometimes if the plugin loaded too soon it will crash tha game because the entity unable to be loaded.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:54.


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