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

[TUT] SourcePawn Scripting - Tips, Basics to Advanced


Post New Thread Reply   
 
Thread Tools Display Modes
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 02-12-2020 , 00:28   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #21

I think it would be a good idea to attach this topic so that no one don't have to search for it in the future also a new sourcemod user will see this topic and maybe this will fix the problem of identical errors and requests for
help such as: no debug stringtable, Error parsing gameconfig file, Language phrase "..." not found and so on
__________________
cry

Last edited by BHaType; 02-12-2020 at 00:37.
BHaType is offline
Send a message via AIM to BHaType
Desktop
AlliedModders Donor
Join Date: Sep 2009
Location: C:\Users\Default\
Old 02-20-2020 , 12:47   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #22

I think it would be nice to add the usage of RequestFrame instead of CreateTimer with 0.1 seconds to execution as a good practice.

For example:
PHP Code:
public Action EventOnPlayerConnectedFull(Event eventchar[] namebool dontBroadcast){

    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
    
RequestFrame(view_as<RequestFrameCallback>(MoveToSpectator), client);
}
public 
Action MoveToSpectator(any data){
    
    
ChangeClientTeam(dataCS_TEAM_NONE);

__________________
Massive Infection:: Piu-Games
Desktop is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 02-20-2020 , 16:36   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #23

Quote:
Originally Posted by Desktop View Post
I think it would be nice to add the usage of RequestFrame instead of CreateTimer with 0.1 seconds to execution as a good practice.
Spoiler
It would depend on the use case, you could be using a repeat timer. Though for the instance you are probably mentioning, it would be a one time with an immediate response. That would be a great use of RequestFrame as it's that's what it should be used for. Though, I would say it would better to have a complete example, along with the newest method of usage. Such as -

PHP Code:
#include <cstrike>

public void OnPluginStart()
{
    
HookEvent("player_connect_full"Event_PlayerConnectFull);
}

public 
void Event_PlayerConnectFull(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
RequestFrame(Frame_ChangeTeamclient);
}

public 
void Frame_ChangeTeam(any client)
{
    
ChangeClientTeam(clientCS_TEAM_NONE)

It should be mentioned that there are scenarios were RequestFrame and using a timer delay are different enough that something such as when a player is spawning and not creating a delay will cause a function to not work. Case scenarios I believe exist, like equipping a weapon, dropping a weapon, or cycling and stripping certain weapons, are such examples.

Of course, correct me if I am wrong, but this was such issues I had awhile ago.
Maxximou5 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 02-21-2020 , 04:47   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #24

// TODO:
Where is a good start for learning VScript system? Some links for novice...

Skip it. Already included in 1st post:
Spoiler
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 03-29-2020 at 09:44.
Dragokas is offline
Desktop
AlliedModders Donor
Join Date: Sep 2009
Location: C:\Users\Default\
Old 02-26-2020 , 08:43   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #25

Quote:
Originally Posted by Maxximou5 View Post
It would depend on the use case, you could be using a repeat timer. Though for the instance you are probably mentioning, it would be a one time with an immediate response. That would be a great use of RequestFrame as it's that's what it should be used for. Though, I would say it would better to have a complete example, along with the newest method of usage. Such as -

PHP Code:
#include <cstrike>

public void OnPluginStart()
{
    
HookEvent("player_connect_full"Event_PlayerConnectFull);
}

public 
void Event_PlayerConnectFull(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
RequestFrame(Frame_ChangeTeamclient);
}

public 
void Frame_ChangeTeam(any client)
{
    
ChangeClientTeam(clientCS_TEAM_NONE)

It should be mentioned that there are scenarios were RequestFrame and using a timer delay are different enough that something such as when a player is spawning and not creating a delay will cause a function to not work. Case scenarios I believe exist, like equipping a weapon, dropping a weapon, or cycling and stripping certain weapons, are such examples.

Of course, correct me if I am wrong, but this was such issues I had awhile ago.
Yes, you're right, that would be a correct case, as you said, sometimes you have to "let things happen" before calling a func to that, like the case when the player equips a weapon or while working with networked entities and you need them to exist first.

There are two ways of using this logic, one is firing a timer for example on a "Pre" event (Time) and the other is to request a frame in the "post" event (requestFrame), both should work similarly on most cases.
The difference is that on the "post" event, you can read/know all the data you need to work with the entity (because you are sure it already exists)
__________________
Massive Infection:: Piu-Games

Last edited by Desktop; 02-26-2020 at 08:50.
Desktop is offline
conglyvaness
New Member
Join Date: Mar 2020
Location: Việt Nam
Old 03-05-2020 , 23:27   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #26

Originally Posted by Silvers
ConVars Anomaly Fixer
__________________
<a href="https://unitedairlines-vn.com/ve-may-bay-di-my">https://unitedairlines-vn.com/ve-may-bay-di-my</a>
conglyvaness is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 03-05-2020 , 23:48   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #27

lol what, not by me... I think you made error posting? I have been meaning to update 1st post for a while, soon eventually I will please bear with me.
__________________

Last edited by Silvers; 03-05-2020 at 23:48.
Silvers is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 03-14-2020 , 16:36   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #28

We're stickied! Thanks! @Mods I'll try to keep this updated over the foreseeable future also feel free to make any changes.

Updated with suggestions from above and added various details to "Information:" part of section 7. Thanks to "JoinedSenses" and "Lux" for some details.

Added the RequestFrame example and one from my own uses.

Dragokas has even more additions coming soon!

Huge thanks to "GAMMACASE" for compiling a list of CS:S and CS:GO fixes, now added to the section 6.
__________________

Last edited by Silvers; 03-14-2020 at 18:00.
Silvers is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-23-2020 , 17:45   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #29

New link to add: https://wiki.alliedmods.net/Csgo_quirks
(it's for discussion, since 2015 year topic, maybe too outdated, need overview from somebody in CSGO world).

Various:
Quote:
net_graph 3
net_graph 4 will show you a bit more info - sv, var. Useful when server experience CPU overloading.

Quote:
you need to compile the plugin with an older version of SM, e.g. 1.9
There are many questions "how to find it?". I'd suggest highlight "1.9" with hyperlink: https://www.sourcemod.net/downloads....=1.9-dev&all=1
(or alternate: https://www.sourcemod.net/smdrop/1.9/ )

======
P.S. More code samples coming soon.


Skip it. Already included in 1st post:
Spoiler
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 03-29-2020 at 10:56.
Dragokas is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 03-24-2020 , 10:17   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #30

Thanks added.

Is + client port really necessary? I don't have mine forwarded and people can connect only when I forward the main port 27016.
__________________
Silvers 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 04:23.


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