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

Storing temporary data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
addemod
Junior Member
Join Date: Feb 2016
Old 02-10-2016 , 11:24   Storing temporary data
Reply With Quote #1

Hello. I have a question about storing temporary date.
In Java or anything similar you have Array lists. How can I achieve this in SourcePawn.

If I am not able to do this in SourcePawn, how would I save the temporary data?
(Data that is updated each round, CS:S)
addemod is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-10-2016 , 12:00   Re: Storing temporary data
Reply With Quote #2

what kind of data?
You can create global arrays in sourcepawn.
Also there is ArrayLists
Mitchell is offline
addemod
Junior Member
Join Date: Feb 2016
Old 02-10-2016 , 13:40   Re: Storing temporary data
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
what kind of data?
You can create global arrays in sourcepawn.
Also there is ArrayLists
Like kill amount per match, damaged taken the whole round, and so on. Like normal integers that I can dynamically change, per client
addemod is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-10-2016 , 13:46   Re: Storing temporary data
Reply With Quote #4

Quote:
Originally Posted by addemod View Post
Like kill amount per match, damaged taken the whole round, and so on. Like normal integers that I can dynamically change, per client
I Suggest looking through the tutorials.
https://wiki.alliedmods.net/Category...eMod_Scripting

You would just create a global variable at the top of the plugin.
OldSyntax:
new Float:gDamageTaken[MAXPLAYERS+1];
New Syntax:
Float gDamageTaken[MAXPLAYERS+1];

Last edited by Mitchell; 02-10-2016 at 13:49.
Mitchell is offline
addemod
Junior Member
Join Date: Feb 2016
Old 02-10-2016 , 14:00   Re: Storing temporary data
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
I Suggest looking through the tutorials.
https://wiki.alliedmods.net/Category...eMod_Scripting

You would just create a global variable at the top of the plugin.
OldSyntax:
new Float:gDamageTaken[MAXPLAYERS+1];
New Syntax:
Float gDamageTaken[MAXPLAYERS+1];
Why the "MAXPLAYERS+1"?

Edit:
Maybe just an example?

Last edited by addemod; 02-10-2016 at 14:01.
addemod is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-10-2016 , 14:05   Re: Storing temporary data
Reply With Quote #6

Quote:
Originally Posted by addemod View Post
Why the "MAXPLAYERS+1"?

Edit:
Maybe just an example?
Easiest way to explain MAXPLAYERS+1:

Say you have 10 slot server
MAXPLAYERS would be 10 (just an example)
However client index's start at 1, because console is client index 0.
So instead of doing client-1 every where you use client, it's easier to just add an extra cell.
Mitchell is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-10-2016 , 14:35   Re: Storing temporary data
Reply With Quote #7

Quote:
Originally Posted by Mitchell View Post
Easiest way to explain MAXPLAYERS+1:

Say you have 10 slot server
MAXPLAYERS would be 10 (just an example)
However client index's start at 1, because console is client index 0.
So instead of doing client-1 every where you use client, it's easier to just add an extra cell.
MAXPLAYERS is a define who's purpose is to hold the value of the max number of players SM supports. Currently the value of the define is 65.
MaxClients is the variable that changes based on what the server's maxplayers is set to.
https://github.com/alliedmodders/sou...lients.inc#L72

Last edited by WildCard65; 02-10-2016 at 14:36.
WildCard65 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-10-2016 , 14:37   Re: Storing temporary data
Reply With Quote #8

Quote:
Originally Posted by WildCard65 View Post
MAXPLAYERS is a define who's purpose is to hold the value of the max number of players SM supports. Currently the value of the define is 65.
https://github.com/alliedmodders/sou...lients.inc#L72
chill it was an example.
I literally added "(just an example)" because I knew someone was going to say this.
You're making it more confusing by explaining it like that.
Mitchell is offline
addemod
Junior Member
Join Date: Feb 2016
Old 02-10-2016 , 16:19   Re: Storing temporary data
Reply With Quote #9

Quote:
Originally Posted by Mitchell View Post
Easiest way to explain MAXPLAYERS+1:

Say you have 10 slot server
MAXPLAYERS would be 10 (just an example)
However client index's start at 1, because console is client index 0.
So instead of doing client-1 every where you use client, it's easier to just add an extra cell.
And why would I want to do that in an array of damage info and such?
addemod is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-10-2016 , 16:29   Re: Storing temporary data
Reply With Quote #10

Quote:
Originally Posted by addemod View Post
And why would I want to do that in an array of damage info and such?
What... If you are wanting to store how much damage a player has done through-out the round you're going to need a global array.
You would need to reset the array with the client in it when ever the round starts and you can display it on round end.
Mitchell 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 12:18.


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