Raised This Month: $ Target: $400
 0% 

[QUESTION]What is the difference betwen these functions


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-07-2015 , 19:04   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #21

Quote:
Originally Posted by aron9forever View Post
So is there any way to stop other plugin's from stopping my task?
I see no params at set_task to make it unstoppable(kek)
Just make the task-id unique. For example: 231431, if it's for running on a player do 231431 + id.
__________________
Bugsy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-08-2015 , 04:45   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #22

In this case it was very clear, wasn't it ?
__________________

Last edited by HamletEagle; 08-08-2015 at 04:46.
HamletEagle is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 08-08-2015 , 14:57   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #23

Quote:
Originally Posted by Bugsy View Post
Just make the task-id unique. For example: 231431, if it's for running on a player do 231431 + id.
any limits on taskid except 32bit integer?
I always used 4 digit numbers till now

I was talking about other bad coded plugins or malicious plugins ending my tasks, either by accident or intentionally, unique id is only unique in my script, who knows what other people put in theirs.

This is a little loophole that should be patched, imagine stopping the banlist checking task of advancedbans for example, you can't even notice this strange activity unless you check both scripts and notice they use the same ids
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-08-2015 , 15:16   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #24

I'm not sure of the data-type used for the id, but even at a minimum it is a signed 16-bit integer, with that you have 32,767 to work with. You're trying to tell me that some other scripter is going to try to decipher what you use as task-id's?

You can always make them dynamic. Create a global array and when the plugin starts (or task is created) load this task-id array with random numbers.

Edit: It's appears to be cell which is 32-bit signed: −2,147,483,648 to 2,147,483,647
Code:
class CTask
{
	// task settings
		
	CPluginMngr::CPlugin *m_pPlugin;
	cell m_iId;
	int m_iFunc;
	int m_iRepeat;
__________________

Last edited by Bugsy; 08-08-2015 at 15:30.
Bugsy is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 08-08-2015 , 17:41   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #25

Quote:
Originally Posted by Bugsy View Post
I'm not sure of the data-type used for the id, but even at a minimum it is a signed 16-bit integer, with that you have 32,767 to work with. You're trying to tell me that some other scripter is going to try to decipher what you use as task-id's?

You can always make them dynamic. Create a global array and when the plugin starts (or task is created) load this task-id array with random numbers.

Edit: It's appears to be cell which is 32-bit signed: −2,147,483,648 to 2,147,483,647
Code:
class CTask
{
	// task settings
		
	CPluginMngr::CPlugin *m_pPlugin;
	cell m_iId;
	int m_iFunc;
	int m_iRepeat;

Yes, that's a good idea, thanks. Also thanks for fetching the info, it's good to know i can use larger numbers
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 08-16-2015 , 13:57   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #26

i have one more question

why are these "{}" used in this case ?

PHP Code:

new bool:gHasSnark    MAX_CLIENTS 1 char ];
new 
bool:gWeaponActiveMAX_CLIENTS 1 char ];
new 
bool:gJustThrown  MAX_CLIENTS 1 char ];

new 
Float:gNextShot      MAX_CLIENTS ];
new 
Float:gTimeWeaponIdleMAX_CLIENTS ];

new 
gPlayerAmmoMAX_CLIENTS 1 char ];

public 
client_connect Player )
{
    
gHasSnark    Player } = false;
    
gWeaponActivePlayer } = false;
    
gJustThrown  Player } = false;
    
gPlayerAmmo  Player } = get_pcvar_numpCvarAmmo );

Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-16-2015 , 14:26   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #27

Because he is declaring the arrays as a packed string using the keyword 'char' after the size value which will reduce the number of cells that are allocated. This is beneficial because it uses every byte within the cell, versus declaring it 'regular' which only uses 1 byte within each cell (4-bytes).

new bool:gHasSnark [ MAX_CLIENTS + 1 char ];

The { } is needed to reference the cell. Doing this saves a bit of memory because it will declare an array of only 33 bytes, versus an array of 132 bytes (33 * 4).

new bool:gHasSnark[ MAX_CLIENTS + 1 = 33 * 4 = 132 bytes of memory
new bool:gHasSnark[ MAX_CLIENTS + 1 char ] = 33 = bytes of memory

More info here: https://forums.alliedmods.net/showthread.php?t=90735

Unfortunately the AMX-X string natives are not built to use packed strings.
__________________

Last edited by Bugsy; 08-16-2015 at 14:30.
Bugsy is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 08-16-2015 , 15:12   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #28

What is better bits or char?
wicho is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-16-2015 , 15:30   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #29

Bits can only be used for storing boolean values, or groups of smaller values-- ie. you can store 16 values between 0-3 within 1 cell. Char is good for storing ascii characters, or any values 0-255 since it is limited to 1 byte.
__________________

Last edited by Bugsy; 08-16-2015 at 15:32.
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 08-16-2015 , 15:42   Re: [QUESTION]What is the difference betwen these functions
Reply With Quote #30

what do you mean by this ?
"Unfortunately the AMX-X string natives are not built to use packed strings"

It could cause server crash? or something? because i encounter server crashes on linux with no error logs running the plugin containing that code, and i couldn't find a solution for several weeks

link here:
https://forums.alliedmods.net/showthread.php?t=270179

Last edited by Depresie; 08-16-2015 at 15:44.
Depresie 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 14:42.


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