Raised This Month: $51 Target: $400
 12% 

my plugin wont run


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
miniman
Senior Member
Join Date: Aug 2009
Location: Israel
Old 12-21-2009 , 11:18   my plugin wont run
Reply With Quote #1

i have problem
PHP Code:
#include <sourcemod>
#include <sdktools>

public Plugin:myinfo 
{
    
name "New Plugin",
    
author "Unknown",
    
description "<- Description ->",
    
version "1.0",
    
url "<- URL ->"
}

//weapons
#define Pistol "weapon_pistol"
#define Rpg "weapon_rpg"
#define Crowbar "weapon_crowbar"
#define Crossbow "weapon_crossbow"
#define Shotgun "weapon_shotgun"
#define Smg "weapon_smg"


new player[128];
new 
String:weapons[6][] = {PistolRpgCrowbarCrossbowShotgunSmg};



public 
OnPluginStart()
{
HookEvent("player_death",Event_player_death)
HookEvent("player_spawn",Event_player_spawn)
HookEvent("item_pickup",Event_item_pickup)
}
public 
Event_player_death(Handle:event, const String:name[], bool:dontBroadcast)
{
        new 
client_attacker GetEventInt(event"attacker");
        
decl String:client_attacker_weapon[60];
        
GetEventString(event,"weapon",client_attacker_weapon,60);
        
PrintToChatAll(client_attacker_weapon);
      if(
strcmp(client_attacker_weapon,weapons[player[client_attacker]],true)==0)
{
             
player[client_attacker]++;
GivePlayerItem(GetClientOfUserId(client_attacker),weapons[player[client_attacker]],0);
PrintToChatAll(player[client_attacker]);
}
}

public 
Event_item_pickup(Handle:event, const String:name[], bool:dontBroadcast)
{
     new 
clientGetEventInt(event"userid");
        new 
String:client_weapon[60];
        
GetEventString(event,"item",client_weapon,60);
    if(
strcmp(client_weapon,weapons[player[client]],true)!=0)
    {        
RemovePlayerItem(GetClientOfUserId(client),FindEntityByClassname(-1,client_weapon));
    }
}


public 
Event_player_spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client_id GetEventInt(event"userid");
    new 
client=GetClientOfUserId(client_id);
    
GivePlayerItem(client,weapons[player[client_id]],0);
}

public 
bool:OnClientConnect(clientString:rejectmsg[], maxlen)
{
player[GetClientUserId(client)]=0;

i wrote this plugin its gungame plugin and its just wont work its compiled fine but when its used in the game it takes no effect at all
miniman is offline
SilentLikeSilence
Senior Member
Join Date: Jul 2009
Old 12-21-2009 , 17:04   Re: my plugin wont run
Reply With Quote #2

Use these

PHP Code:
new client GetClientOfUserId(GetEventInt(event"userid"));
new 
attacker GetClientOfUserId(GetEventInt(event"attacker")); 
OnClientConnect:
"If you return true, the client will be allowed in the server. If you return false (or return nothing), the client will be rejected."
SilentLikeSilence is offline
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 12-22-2009 , 05:07   Re: my plugin wont run
Reply With Quote #3

In other words, GetEventInt() returns userid, which is different than client id. If you need to find a player, use GetClientOfUserId(userid) function, like it has been shown in second post.
__________________
Lord Canistra 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 15:27.


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