Veteran Member
Join Date: Jan 2010
Location: mom's basement
08-21-2020
, 05:30
Re: how do i learn sourcemod?
#2
Look topics from >
Scripting
Look other devs plugin source code *.sp files
From here
https://wiki.alliedmods.net/Main_Page
Look
https://wiki.alliedmods.net/Category...eMod_Scripting
*edit
here little sample
headshot count
Spoiler
PHP Code:
/*
* Server trigger event player_death when player get killed
*
* Server event "player_death", Tick 4582:
* - "userid" = "3"
* - "attacker" = "2"
* - "weapon" = "ak47"
* - "headshot" = "1"
* - "dominated" = "0"
* - "revenge" = "0"
*/
int headshots_array [ MAXPLAYERS ];
public void OnPluginStart ()
{
HookEvent ( "player_death" , player_death );
RegConsoleCmd ( "sm_test" , test );
RegConsoleCmd ( "sm_reset" , reset );
}
public Action test ( int client , int arg )
{
PrintToChat ( client , "Your headshot count %i" , headshots_array [ client ]);
return Plugin_Handled ;
}
public Action reset ( int client , int arg )
{
headshots_array [ client ] = 0 ;
PrintToChat ( client , "You reset headshot count %i" , headshots_array [ client ]);
return Plugin_Handled ;
}
public void player_death ( Event event , char [] name , bool dontBroadcast )
{
// only headshot
if(! event . GetBool ( "headshot" )) return;
int attacker_userid = event . GetInt ( "attacker" ); // userid is like uniq ticket, everytime when enter in server.
int attacker_client_index = GetClientOfUserId ( attacker_userid ); // valid client index 1 to maxplayers
// couldn't find client index in game with given userid
if( attacker_client_index == 0 ) return;
headshots_array [ attacker_client_index ] += 1 ;
PrintToChatAll ( "Player %N headshot count %i" ,
attacker_client_index ,
headshots_array [ attacker_client_index ]);
}
__________________
Do not Private Message @me
Last edited by Bacardi; 08-21-2020 at 05:55 .