Raised This Month: $32 Target: $400
 8% 

SM strangenesses


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
client21
Senior Member
Join Date: Apr 2013
Old 01-26-2018 , 23:50   SM strangenesses
Reply With Quote #1

PHP Code:
stock X(v[])
{
    static 
key 0;
    if (!
keykey 1;
    
    
v[0] += key;

    
PrintToServer("%d"v[0]);
}

public 
OnPluginStart()
{
    
xz();
    
xz();
    
xz();
}

stock xz()
{
    
X({2});

Result:
Code:
3
4
5
What?
client21 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-27-2018 , 01:20   Re: SM strangenesses
Reply With Quote #2

I haven't looked up how SourceMod handles array literals, but chances are it's converting it into either a static or global array variable.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-27-2018 , 04:15   Re: SM strangenesses
Reply With Quote #3

The array literal {2} should be const and the compiler shouldn't allow you to pass it as a non-const parameter. Most likely a bug.
__________________

Last edited by klippy; 01-27-2018 at 04:17.
klippy is offline
client21
Senior Member
Join Date: Apr 2013
Old 03-04-2018 , 05:32   Re: SM strangenesses
Reply With Quote #4

PHP Code:
new Handle:hPack CreateDataPack();
WritePackCell(hPack1);
WritePackCell(hPack2);
    
ResetPack(hPack);
PrintToServer("%d\n%d"ReadPackCell(hPack), ReadPackCell(hPack)); 
Result:

Code:
2
1
SM, you seriously again yes?
Omg.. Where logic in this world..
client21 is offline
client21
Senior Member
Join Date: Apr 2013
Old 03-04-2018 , 05:50   Re: SM strangenesses
Reply With Quote #5

SDKHooks_TakeDamage too stupid..

SDKHooks_TakeDamage(client, 0, owner, 99.0, DMG_BLAST); // client have 1 hp, ok work
SDKHooks_TakeDamage(client, 0, owner, 100.0, DMG_BLAST); // client have 27 hp, nice SM, nice
client21 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-04-2018 , 06:00   Re: SM strangenesses
Reply With Quote #6

Quote:
Originally Posted by client21 View Post
PHP Code:
new Handle:hPack CreateDataPack();
WritePackCell(hPack1);
WritePackCell(hPack2);
    
ResetPack(hPack);
PrintToServer("%d\n%d"ReadPackCell(hPack), ReadPackCell(hPack)); 
Result:

Code:
2
1
SM, you seriously again yes?
Omg.. Where logic in this world..
You will find it working the same way in many languages. It's a common practice that parameters are pushed onto the stack in reverse order. Even C language does that. If you expect something to be done in specific order, don't do it within the function call.

Quote:
Originally Posted by client21 View Post
SDKHooks_TakeDamage too stupid..

SDKHooks_TakeDamage(client, 0, owner, 99.0, DMG_BLAST); // client have 1 hp, ok work
SDKHooks_TakeDamage(client, 0, owner, 100.0, DMG_BLAST); // client have 27 hp, nice SM, nice
You should post more code if you expect to whine about something and want it fixed in case it's a bug. Also given that it's a SDKHooks call and something is wrong indeed, it most likely isn't SM's fault.
__________________

Last edited by klippy; 03-04-2018 at 06:01.
klippy is offline
client21
Senior Member
Join Date: Apr 2013
Old 03-04-2018 , 06:35   Re: SM strangenesses
Reply With Quote #7

Quote:
Originally Posted by KliPPy View Post
You should post more code if you expect to whine about something and want it fixed in case it's a bug. Also given that it's a SDKHooks call and something is wrong indeed, it most likely isn't SM's fault.
You should understand that publishing more code does not make sense, since I gave all the key information. If you do not understand it, this is your problem. Yes, this is a very important remark, sdkhooks is guilty, not SM.

Last edited by client21; 03-04-2018 at 06:35.
client21 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-04-2018 , 07:02   Re: SM strangenesses
Reply With Quote #8

Quote:
Originally Posted by client21 View Post
You should understand that publishing more code does not make sense, since I gave all the key information. If you do not understand it, this is your problem. Yes, this is a very important remark, sdkhooks is guilty, not SM.
It absolutely makes sense, the context in which you call the function matters. To prove that there is a bug one must be able to replicate it. Also any additional information like what game it is, OS etc. would help resolve the issue if there's truly any.
What I meant is that SDKHooks doesn't care at all what value you passed to it, it doesn't differentiate between 99.0 and 100.0 and take action depending on what value it is, it just forwards it to the game AFAIK.
__________________

Last edited by klippy; 03-04-2018 at 07:03.
klippy is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 03-04-2018 , 08:08   Re: SM strangenesses
Reply With Quote #9

The order parameters get pushed to the stack and the order of evaluation of function arguments don't have to be the same, though being the same is simpler. Pawn doesn't define the order of evaluation (and isn't the only language to not define it), though most do define it as left to right.

For SDKHooks_TakeDamage, it's more likely the black box that is the game is doing whatever it is that's weird.
Fyren is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-04-2018 , 09:49   Re: SM strangenesses
Reply With Quote #10

For the TakeDamage part, if this is one of the Counter-Strike games, did either player have armor?
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 02:29.


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