Raised This Month: $319 Target: $400
 79%   Almost there!

[TUT] SourcePawn Scripting - Tips, Basics to Advanced


Post New Thread Reply   
 
Thread Tools Display Modes
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-20-2021 , 19:00   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #51

Quote:
Originally Posted by Dragokas View Post
MAGNAT2645, interesting ability, but IMHO, useless sample =) Can't find where it could be useful. The same can be written by manual string enquoting.
As i said, it's not that useful. You can use it in a macro to join text (and put it without quotes).
Code:
#define ERROR(%0) PrintToServer( "ERROR: " ... #%0 )

int a = 5;
int b = 0;
int c;
if ( b == 0 ) ERROR(Division by zero!);
else          c = a / b;
But, it's better to use quotes for better readability
Code:
#define ERROR(%0) PrintToServer( "ERROR: " ... %0 )
if ( b == 0 ) ERROR( "Division by zero!" );
__________________

Last edited by MAGNAT2645; 08-20-2021 at 19:01.
MAGNAT2645 is offline
zomexf
Junior Member
Join Date: Jul 2019
Old 09-20-2021 , 13:12   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #52

Use OnClientPostAdminCheck or OnClientPutInServer : SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);

Whether it is necessary to use "SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage)" in OnClientDisconnect;

I want to know.
__________________
Sorry, My English is bad

Last edited by zomexf; 09-20-2021 at 13:14.
zomexf is offline
Psyk0tik
AlliedModders Donor
Join Date: May 2012
Location: Homeless
Old 09-20-2021 , 13:20   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #53

Quote:
Originally Posted by zomexf View Post
Use OnClientPostAdminCheck or OnClientPutInServer : SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);

Whether it is necessary to use "SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage)" in OnClientDisconnect;

I want to know.
Hook inside OnClientPutInServer since that's when players join the server. I would only hook inside OnClientPostAdminCheck if you plan on checking admin flags to determine if they should be hooked.

Entities are automatically unhooked by SDKHooks when they leave (if they are player entities) or are deleted.
__________________
AFK like JFK
--
Donate to Motivate
--
Get updated L4D/L4D2 gamedata signatures here.
--
PM me if you need help with finding signatures and/or offsets in the following games: L4D1&2/CSGO/TF2/NMRIH/INS/DODS/CSS/HL2DM
Psyk0tik is offline
Silvers
AlliedModders Donor
Join Date: Aug 2010
Location: SpaceX
Old 09-20-2021 , 13:38   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #54

Using OnClientPostAdminCheck is bad for anything other than when checking for admin flags, since if Steam goes offline they are not verified and the forward will not trigger.
__________________
Silvers is offline
zomexf
Junior Member
Join Date: Jul 2019
Old 09-20-2021 , 14:48   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #55

Thanks.
__________________
Sorry, My English is bad

Last edited by zomexf; 09-20-2021 at 14:53.
zomexf is offline
Reply


Thread Tools
Display Modes

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 11:11.


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