ESF Core 0.3

NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
ESF Core 0.4 Final

I've decided to make some AMXX stocks for ESF Open Beta: Final.

This is what I made so far.

Functions (check esfcore.inc for meanings):
  • GetClass(Client);
  • GetPowerUpColor(Client);
  • SetPowerUpColor(Client, Red, Green, Blue);
  • ResetPowerUpColor(Client);
  • GetAuraColor(Client);
  • SetAuraColor(Client, Color);
  • ResetAuraColor(Client);
  • SetModel(Client, "models/player/Model/Model.mdl");
  • GetHealth(Client);
  • SetHealth(Client, Health);
  • GetPowerLevel(Client);
  • SetPowerLevel(Client, PowerLevel);
  • GetSpeed(Client);
  • SetSpeed(Client, Speed);
  • GetEnergy(Client);
  • SetEnergy(Client, Energy).
If you have any suggestions, feel free to post.

Changelog:
Version 0.4
- Fixed some debug error(s).
Download (DownloadTaxi.com).
N/A (TeamRaD.Game-Server.cc).
 
Last edited:
ESF Coder
🌠 Staff
Joined
Jun 13, 2004
Messages
585
Best answers
0
Location
Austria -> Vienna
nice work
but here some things:
1) you don't have to use serverframe in 1.2.3 to change the model ;)
2) with your code you are unable to set powerup colors where red = 0, so no green or blue ones =(
3) dont use #define AUTHOR <string>, for strings you should use const arrays. ( this will save memory )
4) you forgot c18 and ginyu
5) there must be some other way to get the playerclass instead of catching the cmd.
6) these aren't stocks...these are dynamic natives hehe :p


but these are just some quick thoughts =)
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
1) I've asked (yes, here, in ESForces forums) and nothing seemed to be able to help me with it.
2) Gonna check.
3) Gonna change.
4) Gonna fix.
5) No idea.
6) What I meant is that these are simplified functions.
 
ESF Coder
🌠 Staff
Joined
Jun 13, 2004
Messages
585
Best answers
0
Location
Austria -> Vienna
well that means i guess, that i'm still the only one who was able to hack it correctly xD
well here is our SetModel function i wrote for ecx
Code:
public __setClientMODEL ()
{
	static Client;
	Client = get_param( 1 );
	
	//if ( !validateClient( Client ) ) // this function checks if the player is alive, ingame, connectect, etc.
	//	return 0;

	static Model[ 32 ];
	get_string( 2, Model, 22 );

	static Location[ 65 ];
	formatex( Location, 64, "models/player/%s/%s.mdl", Model, Model );

	if ( !file_exists( Location ) )
	{
		log_error( AMX_ERR_NATIVE, "< Core >> Model does not exist > ^"%s^"", Location );

		return 0;
	}

	
        set_pdata_string( Client, 1420, Model, -1, 20 );
	set_pev( Client, pev_model, Location );
	engfunc( EngFunc_SetModel, Client, Location );

	return 1;
}
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
Well congrats in doing so. ^^

BTW I haven't managed to fix the RGB problem with setting powerup color. :(
 
Last edited:
ESF Coder
🌠 Staff
Joined
Jun 13, 2004
Messages
585
Best answers
0
Location
Austria -> Vienna
boy...
#define test "ASDFASDFASDFASDFASDFASD"
everywhere you write test the compiler will add the "ASDFASDFASDFASDFASDFASD" string.
if you are using it 20 time, you will have it 20 times in the compiled file and then also 20 times in the memory ( and for each their own reference ).
if you are using const test[] = "ASDFASDFASDFASDFASDFASD", then the compiler will generates the string only 1 time, and for the 19 other "calls" it will just use the reference to the single string.
 
Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Nov 6, 2004
Messages
3,055
Best answers
0
Location
Round Rock, TX
#define uses a data buffer. Once the call is finished, the buffer is destroyed and that memory becomes available again. No memory is allocated. Whereas with new const that memory is allocated until the application goes out of scope.
 
ESF Coder
🌠 Staff
Joined
Jun 13, 2004
Messages
585
Best answers
0
Location
Austria -> Vienna
you are mixing up something.
what you mean is stack allocation.
but from where do you think does the program know what data it should put on the stack/heap?
yeah the string. and the string is stored in DAT
here is an quote from Bailopan on his dev log. I hope you understand this.
We noticed that the DAT section is not optimized. You can repeat a string a 800 times and the DAT section will have an entry for each repetition. The solution?
Code:
//BAD
#define COMMON_STRING   "Gaben"
//GOOD
new COMMON_STRING[] = "Gaben"
This way, DAT will only have one reference. Furthermore, it might even be faster because in the case of non-const the compiler won’t have to copy it into the heap first. In many cases you know it will never be modified, and the native declaration simply forgot a ‘const’ keyword.
Another example:
Code:
//BAD
stock GetWeaponName(id, name[], max)
{
   if (id==0)
      copy(name, max, "weapon_none")
   else if (id==1)
      copy(name, max, "weapon_gaben")
   //....
}
//GOOD
new g_WeaponNames[] = {
     "weapon_none", //0
    "weapon_gaben", //1
}
A lookup table is near-instantaneous execution. The compiler simply has to add an integer to a base memory offset. Calling a function is expensive — branch prediction, cache misses, more instructions can add up very quickly. If you’re using the function very often, it’s a good idea to take the time to make these trivial and worth-while optimizations. You can do lookup tables in Small for anything which inputs an integer and outputs any other data type, as long as the set of inputs has fixed limits. It is okay to build the lookup table at runtime, as long as you don’t need to do it often (or building it often outweighs the cost of computing entries totally dynamically).
if you still dont believe me:
write an plugin and use your makro. use your makro about 10 time (should be enough to demonstrate)
and then decompile it and look into the DAT section of the plugin how many times your string gets allocated
and then do the same thing again with "new const" and look again how many times it is allocated

oh btw.
the WHOLE DAT section will be allocated at startup and deleted when the plugin gets unloaded.


and now we should get ontopic again.
feel free to pm me if you still dont believe it
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
I also noticed that BAILOPAN never uses #define SOMETHING "string". ^^

Some of the most experienced AMXX coders are using this though.
 
Last edited:
Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Nov 6, 2004
Messages
3,055
Best answers
0
Location
Round Rock, TX
Wow, that's terrible. See, I've never decompiled an AMXX plugin (never had to). I guess Pawn's internal workings are completely different from C++. My bad.
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
Updated (bump).

BTW why can't I change thread's title? Wanted to change 0.1 (WIP) to 0.2. :(
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
Gosh... What I meant is why members aren't allowed to change thread's title...

EDIT: The title somehow changed. ^^
 
Last edited:
AMXX Coder (:
✔️ HL Verified
Discord Member
Joined
Dec 31, 2008
Messages
55
Best answers
0
wow nice work hlev o_O :cool:
 
Freelance Mappzor
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Nov 21, 2003
Messages
17,065
Best answers
0
Location
Stairing at the Abyss
Gosh... What I meant is why members aren't allowed to change thread's title...

For the reason stated above. Only mods and admins can change topic titles. Since that can only happen with thread moderation tools.

then again if you bug sky enough he may find a pluggin or something ^^


God work with the pluggin though ^^
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
Big update. Check first post.

Only mods and admins can change topic titles.
I'm asking why is it so. Why admins don't want users to change topic titles?

Could some admin/mod change 0.2 to 0.3? Thanks.
 
Last edited:
Former Forcepit Member :(
✔️ HL Verified
💻 Oldtimer
Joined
Aug 21, 2006
Messages
1,717
Best answers
0
Location
korriban
well if a person where able to change topic titles then the would be havok on the forum
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
No, it wouldn't.
 
Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Mar 13, 2005
Messages
3,877
Best answers
0
No, it wouldn't.
Deathshot has posted topic " Hi, how are you? "
Sub has posted in topic " Hi, how are you? "
Madman121 has posted in topic " Hi, how are you? "
Deathshot has changed topic title to " RAPE RAPE LOLOLOLOLOL FAWK YOU! "
FF|Skyrider has posted in topic " RAPE RAPE LOLOLOLOLOL FAWK YOU! "
FF|Skyrider has closed topic " RAPE RAPE LOLOLOLOLOL FAWK YOU! "
Deathshot has been permanently banned


But Anyway On topic. Nice work dude.
 

Users who are viewing this thread

Top Bottom