AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   why this plugin make me crash ? (https://forums.alliedmods.net/showthread.php?t=239282)

Miew 04-25-2014 06:22

why this plugin make me crash ?
 
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();



Bacardi 04-25-2014 08:17

Re: why this plugin make me crash ?
 
which game and are you sure your gamedata files are up to date ?

MasterOfTheXP 04-25-2014 08:19

Re: why this plugin make me crash ?
 
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

kNowo 04-25-2014 08:32

Re: why this plugin make me crash ?
 
Try updating your soul?

Oshizu 04-25-2014 08:37

Re: why this plugin make me crash ?
 
Quote:

Originally Posted by kNowo (Post 2129285)
Try updating your soul?

Now this post just made me confused :shock:

GsiX 04-25-2014 09:10

Re: why this plugin make me crash ?
 
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.

MasterOfTheXP 04-25-2014 10:37

Re: why this plugin make me crash ?
 
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.

blaacky 04-27-2014 06:14

Re: why this plugin make me crash ?
 
I think you need to precache models in OnMapStart rather than OnPluginStart.

Oshizu 04-27-2014 07:14

Re: why this plugin make me crash ?
 
Quote:

Originally Posted by blaacky (Post 2130267)
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 :cry:

GsiX 04-28-2014 01:01

Re: why this plugin make me crash ?
 
Quote:

Originally Posted by Oshizu (Post 2130284)
Precaching stuff on OnPluginStart might work, but it will be unprecached after map changes
So it's only one use trip :cry:

Sometimes if the plugin loaded too soon it will crash tha game because the entity unable to be loaded.


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

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