AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Scripting Forum (https://forums.alliedmods.net/showthread.php?t=52664)

BAILOPAN 03-16-2007 21:39

Scripting Forum
 
This forum is for scripting help, questions, and discussion for SourceMod only. Do not post requests about other projects.

For more information about the SourcePawn language, please see: http://www.sourcemod.net/sdk.php

All questions related to working with SourcePawn/SourceMod are welcome!

Quick Primer
Loading SourceMod
See Installing SourceMod.

Run-time Info
Type "sm" in your server console to get a run-time menu, server-side, for SourceMod.

Coding Plugins
See the SDK for more information. There are example plugins in the "scripting" folder of the SourceMod package. General scripting language introductions will be available soon.

Compiling Plugins
In Windows, open up a command prompt and use:
Code:

cd <sourcemod>\scripting
spcomp myplugin.sp

In Linux, use:
Code:

./spcomp myplugin.sp
Running Plugins
Simply put the .smx (not .sp) file in the SourceMod "plugins" folder.

jopmako 03-17-2007 03:47

Re: Scripting Forum
 
GJ to SourceMod Dev Team.
Cheer!

sn4k3 03-17-2007 06:49

Re: Scripting Forum
 
I cant wait for test this :)
good job

Juba_PornBorn 06-12-2007 20:49

Re: Scripting Forum
 
Noob question. What tool or script program is used to code source plugins sp?

teame06 06-12-2007 20:50

Re: Scripting Forum
 
Quote:

Originally Posted by Juba_PornBorn (Post 488897)
Noob question. What tool or script program is used to code source plugins sp?

Notepad, Crimson Editor, any text editor :o

Juba_PornBorn 06-12-2007 21:04

Re: Scripting Forum
 
So at the moment there's no tool wich in compiling tells you wich are the scripting errors like amxx? I feel like a donkey watching a palace!

Just when I was starting to understand amxx pawn I feel I have to give the next step to what will be the future in gaming but I feel this wont be easy.

theY4Kman 06-12-2007 21:09

Re: Scripting Forum
 
The compiler tells you what and where the errors are, yes. It's pretty easy to tell where your errors are even without something telling you :P

FlyingMongoose 06-12-2007 21:11

Re: Scripting Forum
 
Except when it's the "omgwtfimanub" errors...like a bad path >.<

theY4Kman 06-12-2007 22:22

Re: Scripting Forum
 
Oi! Go pester someone of your own skill level :D

Peoples Army 08-04-2007 11:39

Re: Scripting Forum
 
i wanted to get the sdk but its a tarbell file . what the hell is that and how do i open it ?????

dalto 08-04-2007 12:09

Re: Scripting Forum
 
Quote:

Originally Posted by Peoples Army (Post 512418)
i wanted to get the sdk but its a tarbell file . what the hell is that and how do i open it ?????

It is in tar format commonly used in *nix environments.

Use 7-Zip to open it on Windows.

EDIT: Also, you don't need the SDK to write scripts. Everything you need is in the main distribution.

Peoples Army 08-04-2007 14:40

Re: Scripting Forum
 
yeah ill take a look thru my includes too see . thanks

frozenarmageddon 12-22-2008 20:54

Re: Scripting Forum
 
Quote:

Originally Posted by BAILOPAN (Post 453313)
Compiling Plugins
In Windows, open up a command prompt and use:
Code:

cd <sourcemod>\scripting
spcomp myplugin.sp


Maybe im just stupid... or just did something wrong [its hard to think clear at 3:47 AM] but it says:
Code:

'spcom' is not recognized as an internal or external command, operable program or batch file.
anyway to fix? :stupid:
__________________

I can try to make a nice compiler and code editing program in java, as soon as I fugure out how to compile ._.

naris 12-23-2008 04:48

Re: Scripting Forum
 
Quote:

Originally Posted by frozenarmageddon (Post 731742)
'spcom' is not recognized as an internal or external command, operable program or batch file.

Quote:

Originally Posted by BAILOPAN (Post 453313)
./spcomp myplugin.sp

Try spcomp like it says instead of spcom :nono:

naris 12-23-2008 04:50

Re: Scripting Forum
 
Quote:

Originally Posted by frozenarmageddon (Post 731742)
[its hard to think clear at 3:47 AM]

I think that's the problem -- I've been there :avast:

frozenarmageddon 12-23-2008 05:52

Re: Scripting Forum
 
lol, I didn't see the "p" thanks for clearing it out for me :oops:

btw, anuther way to compile evrything [in your scripting folder, or where your "compile.exe\spcomp.exe" is] is just double clicking it and\or putting a shortcut of the compiler in an easly accessible place ^_^

My idea was of creating a batch file to compile from the desktop and then sending it to the game's addons\sourcemod folder because I am not aware of any kind of scripting tool that actualy uses the scripting folder as base ^_^ I may upload it or its content if I will actualy do it :D

[Didn't tried it yet because I wanted to actualy code first, so if im wrong just remove this part :wink:]

Edit: SM mods\makers\creators\whatever, if you are plannig to make something like the "AMX Mod X Studio" for SM please tell me so I wont waste my time on a java app if eventualy there will be a nice big program [probebly even more stable and usefull than mine] that can replace mine :|

DJ Tsunami 12-23-2008 07:09

Re: Scripting Forum
 
Pawn Studio? Uses the scripting folder as a base if you point it to spcomp.exe, puts plugins in the plugins folder.

frozenarmageddon 12-24-2008 09:31

Re: Scripting Forum
 
DJ Tsunami [DJ?!] thx alot for telling me about PawnStudio [even tho you just wrote its name], didn't even know of its existence, now I can finnaly script SourcePawn easly :D

.:ViruS:. 01-04-2010 06:59

Re: Scripting Forum
 
Quote:

Originally Posted by frozenarmageddon (Post 731742)
Maybe im just stupid... or just did something wrong [its hard to think clear at 3:47 AM] but it says:
Code:

'spcom' is not recognized as an internal or external command, operable program or batch file.
anyway to fix? :stupid:
__________________

paste this in notepad.

@Echo off
color 0a
cd D:\Sourcemod\scripting
spcomp test.sp
pause

change the D:\Sourcemod\scripting to your location
and the test.sp as yourfilename.sp
save it as a .bat and open it. it will work
every time you got a difrent file right click the bat and select edit. then change the sp. line again

Ritsuka 02-28-2010 20:53

Re: Scripting Forum
 
I am getting a problem with it adding banns and locking them. It does not seem to keep the bans for much time at all. I am not sure what to add to it to fix it. I looked in the .sp and could not find anything wrong with it.

mehelp 07-19-2011 06:11

Re: Scripting Forum
 
need help adding comma separator between digits to number, displaying in chat

want chat to display player's points on infected death with comma after thousand, for instance:
stupid (10,222) got 1 point for killing infected
can't get 10222 number with comma
what doI do with this:
PrintToChat(i, "%s (%i) got point for killing Infected", Name, (ClientPoints[i] + CurrentPoints[i]));

was advised to go
http://forums.alliedmods.net/showpos...45&postcount=5
but that requires amxmod. what's the way for sourcemod?

Powerlord 07-19-2011 10:55

Re: Scripting Forum
 
Quote:

Originally Posted by mehelp (Post 1513675)
need help adding comma separator between digits to number, displaying in chat

want chat to display player's points on infected death with comma after thousand, for instance:
stupid (10,222) got 1 point for killing infected
can't get 10222 number with comma
what doI do with this:
PrintToChat(i, "%s (%i) got point for killing Infected", Name, (ClientPoints[i] + CurrentPoints[i]));

was advised to go
http://forums.alliedmods.net/showpos...45&postcount=5
but that requires amxmod. what's the way for sourcemod?

You really should post this as its own thread.

Having said that, here's a quick and completely untested port of the AddCommas function to SourceMod. SourceMod only has a float absolute value function, so I did a two's complement to swap the sign.

PHP Code:

stock AddCommasiNumString:szOutput[] , iLen )
{
    new 
String:szTmp15 ] , iOutputPos iNumPos iNumLen;
    
    if ( 
iNum )
    {
        
szOutputiOutputPos++ ] = '-';
        
iNum = ~iNum 1// Two's complement conversion
    
}
    
    
iNumLen IntToStringiNumszTmpsizeof(szTmp));
    
    if ( 
iNumLen <= )
    {
        
iOutputPos += strcopyszOutputiOutputPos ] , iLen szTmp );
    }
    else
    {
        while ( ( 
iNumPos iNumLen ) && ( iOutputPos iLen ) )
        {
            
szOutputiOutputPos++ ] = szTmpiNumPos++ ];
            
            if ( ( 
iNumLen iNumPos ) && !( (iNumLen iNumPos ) % ) )
            {
                
szOutputiOutputPos++ ] = ',';
            }
        }
        
        
szOutputiOutputPos ] = '\0';
    }
    
    return 
iOutputPos;



mehelp 07-19-2011 12:27

Re: Scripting Forum
 
Quote:

Originally Posted by Powerlord (Post 1513837)
You really should post this as its own thread.

Having said that, here's a quick and completely untested port of the AddCommas function to SourceMod. SourceMod only has a float absolute value function, so I did a two's complement to swap the sign.

well, I kinda did post it as a thread at first, but occasionally at 'amxmod scripting help'. that was my first post and already turned out to be a spam, so didn't want to multiply threads.

thank you for your peace of code, it' just doesn't seem like I'm capable of inserting it properly to plugin). if I put it before the block, responsible for displaying client points on infected death, plugin compiles perfectly, but there's no effect - numbers are still displayed in gamechat with no comma between digits. and when I tried to put indicated code directly in the block , I couldn't compile a thing- got like undefined symbols.. pretty sure I'm doing something wrong)).
here's where I tried to insert it, but failed (peace of [L4D & L4D2] Custom Player Stats v1.4B105 by muukis, just attempting to adopt to how I'd like stats to be displayed):

PHP Code:

// Display common Infected scores to each player.

public Action:timer_ShowTimerScore(Handle:timerHandle:hndl)
{
    if (
StatsDisabled())
        return;

    new 
Mode GetConVarInt(cvar_AnnounceMode);
    
decl String:Name[MAX_LINE_WIDTH];
    
    new 
maxplayers GetMaxClients();
    for (new 
1<= maxplayersi++)
    {
        if (
IsClientConnected(i) && IsClientInGame(i) && !IsClientBot(i))
        {
            
// if (CurrentPoints[i] > GetConVarInt(cvar_MaxPoints))
            //     continue;
            
            
            
TimerPoints[i] = GetMedkitPointReductionScore(TimerPoints[i]);
            
            if (
TimerPoints[i] > && TimerKills[i] > 0)
            {
                if (
Mode == || Mode == 2)
                {
                    
GetClientName(iNamesizeof(Name));
                    
CPrintToChat(i"{blue}%s \x01(%i) got points for killing Infected"Name, (ClientPoints[i] + CurrentPoints[i]));
                }
                else if (
Mode == 3)
                {
                    
GetClientName(iNamesizeof(Name));
                    
StatsPrintToChatAll("\x05%s \x01has earned \x04%i \x01points for killing \x05%i \x01Infected!"NameTimerPoints[i], TimerKills[i]);
                }
            }

            
InterstitialPlayerUpdate(i);
        }

        
TimerPoints[i] = 0;
        
TimerKills[i] = 0;
        
TimerHeadshots[i] = 0;
    }




Powerlord 07-19-2011 13:09

Re: Scripting Forum
 
Quote:

Originally Posted by mehelp (Post 1513903)
well, I kinda did post it as a thread at first, but occasionally at 'amxmod scripting help'. that was my first post and already turned out to be a spam, so didn't want to multiply threads.

thank you for your peace of code, it' just doesn't seem like I'm capable of inserting it properly to plugin). if I put it before the block, responsible for displaying client points on infected death, plugin compiles perfectly, but there's no effect - numbers are still displayed in gamechat with no comma between digits. and when I tried to put indicated code directly in the block , I couldn't compile a thing- got like undefined symbols.. pretty sure I'm doing something wrong)).
here's where I tried to insert it, but failed (peace of [L4D & L4D2] Custom Player Stats v1.4B105 by muukis, just attempting to adopt to how I'd like stats to be displayed):

PHP Code:

// Display common Infected scores to each player.

public Action:timer_ShowTimerScore(Handle:timerHandle:hndl)
{
    if (
StatsDisabled())
        return;

    new 
Mode GetConVarInt(cvar_AnnounceMode);
    
decl String:Name[MAX_LINE_WIDTH];
    
    new 
maxplayers GetMaxClients();
    for (new 
1<= maxplayersi++)
    {
        if (
IsClientConnected(i) && IsClientInGame(i) && !IsClientBot(i))
        {
            
// if (CurrentPoints[i] > GetConVarInt(cvar_MaxPoints))
            //     continue;
            
            
            
TimerPoints[i] = GetMedkitPointReductionScore(TimerPoints[i]);
            
            if (
TimerPoints[i] > && TimerKills[i] > 0)
            {
                if (
Mode == || Mode == 2)
                {
                    
GetClientName(iNamesizeof(Name));
                    
CPrintToChat(i"{blue}%s \x01(%i) got points for killing Infected"Name, (ClientPoints[i] + CurrentPoints[i]));
                }
                else if (
Mode == 3)
                {
                    
GetClientName(iNamesizeof(Name));
                    
StatsPrintToChatAll("\x05%s \x01has earned \x04%i \x01points for killing \x05%i \x01Infected!"NameTimerPoints[i], TimerKills[i]);
                }
            }

            
InterstitialPlayerUpdate(i);
        }

        
TimerPoints[i] = 0;
        
TimerKills[i] = 0;
        
TimerHeadshots[i] = 0;
    }




You need to actually call it. For instance, to format the points in the modes 1 and 2 block above:
PHP Code:

new String:szPoints[15];
GetClientName(iNamesizeof(Name));
AddCommas((ClientPoints[i] + CurrentPoints[i]), szPointssizeof(szPoints));
CPrintToChat(i"{blue}%s \x01(%s) got points for killing Infected"NameszPoints); 


mehelp 07-19-2011 13:59

Re: Scripting Forum
 
got it now. thank you for pointing. did as you recommended
PHP Code:

new String:szPoints[15];
GetClientName(iNamesizeof(Name));
AddCommas((ClientPoints[i] + CurrentPoints[i]), szPointssizeof(szPoints)); CPrintToChat(i"{blue}%s \x01(%s) got points for killing Infected"NameszPoints); 

got following:
name(1) got points for killing infected
name(1)got points for killing infected
"1" value never changed.
is this because there's sum of clientPoints+current , maybe it'll display properly if referred to some separate value, like just client points or only current (but need some time to earn 1000 currentpoints to see if there's comma:))?
or should I install whole piece of code before the block correctly ( I did try that and nothing compiled because of: "AddCommas" already defined)
also I tried
PHP Code:

new String:szPoints[15];
GetClientName(iNamesizeof(Name));
AddCommas((ClientPoints[i] + CurrentPoints[i]), szPointssizeof(szPoints));
CPrintToChat(i"{blue}%s \x01(%s) got points for killing Infected"Name, (ClientPoints[i] + CurrentPoints[i])); 

and got:
name (t)) got points for killing Infected
name(v)) got points for killing Infected
nema (x)) got points for killing Infected
and lots of other different symbols))

mehelp 07-19-2011 14:19

Re: Scripting Forum
 
ok tried displaying currentPoints only:

PHP Code:

AddCommas((CurrentPoints[i]), szPointssizeof(szPoints));
CPrintToChat(i"{blue}%s \x01(%s) got points for killing Infected"NameszPoints); 

until (999) points been displaying correctly, then it became (1) and steady

Powerlord 07-19-2011 14:22

Re: Scripting Forum
 
Likely the problems are being caused by SourceMod storing strings differently than AMX Mod X does. I'll have to check what needs to be changed to get this working like it should.

Powerlord 07-19-2011 14:29

Re: Scripting Forum
 
Here's a new version with a few string handling functions changed around to use the ones that deal with bytes rather than cells (which are 4 bytes each).

PHP Code:

stock AddCommasiNumString:szOutput[] , iLen )
{
    new 
String:szTmp15 ] , iOutputPos iNumPos iNumLen;
    
    if ( 
iNum )
    {
        
szOutputiOutputPos++ ] = '-';
        
iNum = ~iNum 1// Two's complement conversion
    
}
    
    
IntToStringiNumszTmpsizeof(szTmp));
    
iNumLen strlen(szTmp);
    
    if ( 
iNumLen <= )
    {
        
iOutputPos += StrCatszOutput iLen szTmp );
    }
    else
    {
        while ( ( 
iNumPos iNumLen ) && ( iOutputPos iLen ) )
        {
            
szOutputiOutputPos++ ] = szTmpiNumPos++ ];
            
            if ( ( 
iNumLen iNumPos ) && !( (iNumLen iNumPos ) % ) )
            {
                
szOutputiOutputPos++ ] = ',';
            }
        }
        
        
szOutputiOutputPos ] = '\0';
    }
    
    return 
iOutputPos;



mehelp 07-19-2011 14:32

Re: Scripting Forum
 
Quote:

Originally Posted by Powerlord (Post 1513983)
Likely the problems are being caused by SourceMod storing strings differently than AMX Mod X does. I'll have to check what needs to be changed to get this working like it should.

thank you, Powerlord, you so fine. even if it won't work, it's nice to try

mehelp 07-19-2011 14:50

Re: Scripting Forum
 
Quote:

Originally Posted by Powerlord (Post 1513983)
Likely the problems are being caused by SourceMod storing strings differently than AMX Mod X does. I'll have to check what needs to be changed to get this working like it should.

ok tried
PHP Code:

new String:szTmp15 ];
GetClientName(iNamesizeof(Name));
AddCommas((ClientPoints[i] + CurrentPoints[i]), szTmpsizeof(szTmp));
CPrintToChat(i"{blue}%s \x01(%s) got points for killing Infected"NameszTmp); 

same result : name (1) got points... but trying new version made me feel happy somehow lol

btw, there is another shtick about displaying stats - when it's about special infected, for exapmple:
"Name(1,111) got points for (1)Boomer" , boomer is shown with number if there's few of them currently spawned on the map; like when you look at players list thru adminmenu - it says 1. Hunter, 2. (1)hunter, when there's couple of infected of the same tipe. but when you killed (1)Boomer, you can assume there's more nearby, which should be a surprise I suppose. got no clue how to deal with this characters in front of infected name..

mehelp 07-23-2011 23:22

Re: Scripting Forum
 
berni shared tis :)
PHP Code:

stock FormatNumberInt(valueString:buffer[], sizeseperator=',')
{
    
decl String:helper[size];
    
IntToString(valuehelpersize);
    
strcopy(buffersizehelper);

    new 
length strlen(helper);

    new 
n_helper;

    if (
helper[0] == '-') {
        
n_helper += ((length-1) % 3) + 1;

        if (
n_helper == 1) {
            
n_helper 4;
        }
    }
    else {
        
n_helper += length 3;

        if (
n_helper == 0) {
            
n_helper 3;
        }
    }

    new 
n_buffer n_helper;

    while (
n_helper length) {
        
buffer[n_buffer] = seperator;
        
strcopy(buffer[n_buffer 1], sizehelper[n_helper]);

        
n_buffer += 4;
        
n_helper += 3;
    }



FaTony 10-12-2012 18:35

Re: Scripting Forum
 
Quote:

Originally Posted by BAILOPAN (Post 453313)
For more information about the SourcePawn language, please see: http://www.sourcemod.net/sdk.php

Broken link.

Powerlord 10-16-2012 09:10

Re: Scripting Forum
 
Quote:

Originally Posted by FaTony (Post 1817618)
Broken link.

I assume the link is supposed to be to http://docs.sourcemod.net/api/

Cerium 01-01-2014 04:38

Re: Scripting Forum
 
Is there a official IRC channel for alliedmods?

Powerlord 01-01-2014 14:51

Re: Scripting Forum
 
Quote:

Originally Posted by Cerium (Post 2079277)
Is there a official IRC channel for alliedmods?

Yes

Koga73 03-20-2014 18:47

Re: Scripting Forum
 
/ Edit. ~Removed.

kar731 03-29-2016 21:35

Re: Scripting Forum
 
Hi, I'm new to making plugins for CS:GO and I was wondering how I can block footstep noises for people inside of an array? I already have the people in the array, I just can't figure out how to block their footstep noises.

Mitchell 03-30-2016 01:00

Re: Scripting Forum
 
Quote:

Originally Posted by kar731 (Post 2406787)
Hi, I'm new to making plugins for CS:GO and I was wondering how I can block footstep noises for people inside of an array? I already have the people in the array, I just can't figure out how to block their footstep noises.

Try using the search function.

sastdk 04-13-2019 09:14

Re: Scripting Forum
 
1 Attachment(s)
Hello guys, i know is a probably stupid question, but can you tell me how i can set a maximum health for a vip?
I am a begginer and I kinda wanna to learn, thanks.


All times are GMT -4. The time now is 03:47.

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