28.01.2014, 13:14
Speed Testing
Hello guys, I decided to write my first tutorial about Speed Testing in SA-MP for a while now and I decided to take off.
1 - Pages that might help
https://sampwiki.blast.hk/wiki/GetTickCount
https://sampwiki.blast.hk/wiki/Printf
2 - A first code.
To set up a speed test you need to use on of the 'public's' in your pawno, lets take a code to test.
pawn Код:
public OnGameModeInit()
{
LoadMap(); // Custom stock loading my maps.
SetGameModeText(TEXT_GAMEMODETEXT); // Setting the gamemode text to my defined gamemode name.
AddPlayerClass(0, 163.81, 4028.46, 4.06, 0.0, 0, 0,0,0,0,0); // Creating the class
EnableStuntBonusForAll(0); // Disabling Stunt Bonus
return 1;
}
pawn Код:
public OnGameModeInit()
{
new OnGameModeInitCount = GetTickCount(); // creating the OnGameModeInit count.
LoadMap(); // Custom stock loading my maps.
SetGameModeText(TEXT_GAMEMODETEXT); // Setting the gamemode text to my defined gamemode name.
AddPlayerClass(0, 163.81, 4028.46, 4.06, 0.0, 0, 0,0,0,0,0); // Creating the class
EnableStuntBonusForAll(0); // Disabling Stunt Bonus
printf("Excecuted OnGameModeInit, time taken: %d", GetTickCount() - OnGameModeInitCount); // Printing the time which is taken.
return 1;
}
pawn Код:
new OnGameModeInitCount = GetTickCount();
pawn Код:
printf("Excecuted OnGameModeInit, time taken: %d", GetTickCount() - OnGameModeInitCount);
pawn Код:
GetTickCount() - OnGameModeInitCount
3 - Outro
I hope you guys got helped a bit with this tutorial, it's my first tutorial so critism is always allowed, I'd love to learn from you too!