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

[INC] HPVars - Player variable's


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hirsw0w
Junior Member
Join Date: Jul 2014
Old 09-05-2014 , 06:39   [INC] HPVars - Player variable's
Reply With Quote #1

HPVars
by Hirsw0w

Description:

This Include used for save player variable's without new parameters,
The Idea came from SAMP and this is neccery thing there.
the use is simple and not need to much, the save for Float,Int and string.

Defines:


Code:
#define MAX_VARNAME 32 // max var name length
#define MAX_VARINPUT 128 // max var input length
#define MAX_PLAYERS 32 // max players define
#define MAX_VARS 50 // max vars in once
Functions:

Code:
Set:
[[SetPVarString(playerid,varname[],varinput[]) // create\set string in player var.
SetPVarInt(playerid,varname[],varinput) // create\set int in player var.
SetPVarFloat(playerid,varname[],Float:varinput) // create\set Float in player var.

Get:
GetPVarString(playerid,varname[]) // get string from player var.
GetPVarInt(playerid,varname[]) // get int from player var.
GetPVarFloat(playerid,varname[]) // get Float from player var.

Others:
[DeletePVar(playerid,varname[]) // delete player var.
DeleteAllPVars(playerid) // delete all player vars
ResetVars() // reset all players vars.
code:


http://pastebin.com/s3EFj57G


I know that really easy to make, but that good,
sorry for my bad english and if you have comments for this i love to hear that.
builed by me.


Enjoy!!!
Attached Files
File Type: inc hpvars.inc (1.9 KB, 320 views)
Hirsw0w is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 09-05-2014 , 06:48   Re: [INC] HPVars - Player variable's
Reply With Quote #2

MAX_PLAYERS is already defined by default in 1.8.3, so you need to change your define to something else.


What is the point of this include file?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Hirsw0w
Junior Member
Join Date: Jul 2014
Old 09-05-2014 , 07:15   Re: [INC] HPVars - Player variable's
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
MAX_PLAYERS is already defined by default in 1.8.3, so you need to change your define to something else.


What is the point of this include file?
the include is save variable for player like:

SetPVarInt(id,"points",1500);
GetPVarInt(id,"points");

and this save things and you dont need to do:

new Points[32];
and this save place and more comftubale
Hirsw0w is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 09-05-2014 , 07:46   Re: [INC] HPVars - Player variable's
Reply With Quote #4

What kind of benefit does this include offer? Readability is definitely not one of them.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Hirsw0w
Junior Member
Join Date: Jul 2014
Old 09-05-2014 , 07:55   Re: [INC] HPVars - Player variable's
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
What kind of benefit does this include offer? Readability is definitely not one of them.
listen I don't know what to say to you, I know that good and this save lines and you don't need to create 1000 parameters...... and this saving you that work..

you can set string like float or int and get float or int like your chose... and you dont need convert string to float and that uppside. that good for some things I sure you find something to use it.
Hirsw0w is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-05-2014 , 11:58   Re: [INC] HPVars - Player variable's
Reply With Quote #6

The amount of memory you occupy by doing:
Code:
new nVar[MAX_PLAYERS][MAX_VARS][MAX_VARNAME];
new iVar[MAX_PLAYERS][MAX_VARS][MAX_VARINPUT]
is very expensive. If more than one plugin uses this system, you are now multiplying this memory usage by the number of plugins.

Also, having to look up a string within MAX_VARS before you can get/set a variable, makes these operations expensive too. Converting integers and floats to strings and back makes it even worse. Referencing/setting a variable is very fast in pawn; this system adds extra native calls for these simple operations.

The "ease of use" for "not creating" the variables is greatly outweighed by the extra memory and operations included in this system.

Other suggestions:


Look into Tries:

Last edited by Emp`; 09-05-2014 at 12:01.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 09-05-2014 , 14:45   Re: [INC] HPVars - Player variable's
Reply With Quote #7

Quote:
Originally Posted by Hirsw0w View Post
the include is save variable for player like:

SetPVarInt(id,"points",1500);
GetPVarInt(id,"points");

and this save things and you dont need to do:

new Points[32];
and this save place and more comftubale
Comfortable? When coding was something "comfortable" for the one who codes? This is just a waste of resources anyway, huge memory waste for just doing a function, which is useless when knowing how to assign a value to a variable easily
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-10-2014 , 10:32   Re: [INC] HPVars - Player variable's
Reply With Quote #8

@Emp, you mean like this ?

player_vars.inc


I used Trie[g/s]etArray because a trie is not a heterogeneous container, so it can't store both cell & multicell.
__________________
HamletEagle is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-10-2014 , 12:31   Re: [INC] HPVars - Player variable's
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
@Emp, you mean like this ?

player_vars.inc


I used Trie[g/s]etArray because a trie is not a heterogeneous container, so it can't store both cell & multicell.
This is betterbecause it uses Tries, but you also lost the functionality of having custom names associated for the variables, which is what Hirsw0w was advocating. Your system only allows one variable per id number, but you could use incrementing offsets to get different id numbers.

But this is still adding extra native calls for getting/setting a variable. Below is a note from cellarray.inc, but I feel it applies to this too:
Code:
/**
 * These arrays are intended to be used for a form of global storage without 
 * requiring a #define that needs to be increased each time a person needs more 
 * storage.
 * These are not designed to be used as a replacement for normal arrays, as
 * normal arrays are faster and should be used whenever possible.
 */

Last edited by Emp`; 09-10-2014 at 12:32.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-11-2014 , 06:01   Re: [INC] HPVars - Player variable's
Reply With Quote #10

Quote:
but you could use incrementing offsets to get different id numbers.
What do you mean by this ?
__________________
HamletEagle 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 08:40.


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