Re: Today I learned - Share your newly found knowledge! -
Emmet_ - 15.02.2014
Today, I've learned that you can use "strunpack" as opposed to "format" to copy strings:
pawn Code:
new
str[13];
strunpack(str, "Hello there!");
I've not yet found any abnormalities or issues (I've tested smaller cells and bigger outputs), but it's significantly faster than using "format".
Re: Today I learned - Share your newly found knowledge! -
Whitetiger - 15.02.2014
TIL GetPlayerTime is just a server-sided value meaning:
pawn Code:
public OnPlayerSpawn(playerid) {
SetPlayerTime(playerid, 7, 0);
TogglePlayerClock(playerid, 1);
SetTimerEx("ClockUpdate", 5000, 0, "d", playerid);
}
forward ClockUpdate(playerid);
public ClockUpdate(playerid) {
new hour, minute;
GetPlayerTime(playerid, hour, minute);
printf("%02d:%02d", hour, minute);
}
if the user is using a speedhack (via cheat engine for example) it will return an increase of only 5 seconds no matter what even if your time is completely different on client-side.
Re: Today I learned - Share your newly found knowledge! -
Emmet_ - 17.02.2014
Today, I learned that you can access the index of a returned string from a function!
pawn Code:
stock returnString() {
static str[24];
str = "Hello there!";
return str;
}
public OnFilterScriptInit() {
print((returnString())[1]);
}
Prints:
Re: Today I learned - Share your newly found knowledge! -
Dubya - 18.02.2014
Today I Learned that there is no plugin or support for casinos! Would be great if someone made something like this, could be useful for roleplay servers.
Re: Today I learned - Share your newly found knowledge! -
Vince - 18.02.2014
Today I learned that you can actually pass "inline" arrays to functions;
pawn Code:
if(in_array(GetPlayerWeapon(playerid), {22,26,28,29,30,31,32}))
{
printf("stuff");
}
else
{
printf("no stuff");
}
pawn Code:
in_array(needle, const haystack[], size = sizeof haystack)
{
for(new i; i < size; i++)
if(haystack[i] == needle) return true;
return false;
}
Re: Today I learned - Share your newly found knowledge! -
Whitetiger - 19.02.2014
Warning: bit off topic
Quote:
Originally Posted by Slice
Today I learned that the anti-DoS timeout issues can be fixed by constantly unbanning the IP of a player experiencing problems.
Obviously a pretty bad solution, but it's better than nothing.
|
out of curiosity can this also fix the reconnect issues on test servers when restarting/gmxing? (with fixes2 plugin maybe? - since OnPlayerConnect is never called, and only that "incoming connection..."). since 0.3z, it seems as though kye "whitelisted" 127.0.0.1. you don't get that message only if your hosting the server, but when I need to test with more than 1 PC that obviously doesn't work (why is 192.168.*.* not whitelisted?) more-over, I thought this was "increased connection security to sa-mp servers against cheaters" when it was first added, but yet, the cheaters have long bypassed it so why is it not removed all together since it's just causing problems on test servers?
Re: Today I learned - Share your newly found knowledge! -
RoboN1X - 28.03.2014
Sorry to bump this topic, but i don't think last post is old enough.
Today i learned that i can just simply use
return on function for a
true/
false statement.
Example:
pawn Code:
IsValidSkin(skinid) // For 0.3d RC5 and upper!
{
if(skinid >= 0 && skinid <= 299 && skinid != 74)
{
return true;
}
return false;
}
can be also written like:
pawn Code:
IsValidSkin(skinid) // For 0.3d RC5 and upper!
return (0 <= skinid <= 299 && skinid != 74);
Re: Today I learned - Share your newly found knowledge! -
TomatoRage - 28.03.2014
New function i know its in the pawno
Re: Today I learned - Share your newly found knowledge! -
Kyance - 28.03.2014
Learned some "new File:...." stuff thanks to Konstantinos
(Checking for strings/parts-or something close to that- and other stuff xd)
Re: Today I learned - Share your newly found knowledge! -
jakejohnsonusa - 28.03.2014
Today I learned that INVALID_PLAYER_ID holds a single integer value.
Re: Today I learned - Share your newly found knowledge! -
AssMunchingFool - 29.03.2014
Quote:
Originally Posted by TomatoRage
New function i know its in the pawno
|
ah no its not? i think this is a custom function its an include not default function
Re: Today I learned - Share your newly found knowledge! -
TomatoRage - 29.03.2014
Quote:
Originally Posted by AssMunchingFool
ah no its not? i think this is a custom function its an include not default function
|
I didn't include anything new and the function worked fine
Re: Today I learned - Share your newly found knowledge! -
Niko_boy - 29.03.2014
Quote:
Originally Posted by TomatoRage
I didn't include anything new and the function worked fine
|
no idea how that even worked without include cuz i am quite sure there is no native function like that exist unless you create a function in your gamemode/fs itself or it is included through other includes (non samp package ones).
Even wiki says:
https://sampwiki.blast.hk/wiki/GetPlayerID , that - "Important Note: This is a custom function, which can be found in Useful_Functions." which clears it doesnt exist by default anyway.
Quote:
Originally Posted by Robo_N1X
Sorry to bump this topic, but i don't think last post is old enough.
|
lol , otherwise too there should be no problem in bumping a thread like this :P
Re: Today I learned - Share your newly found knowledge! -
Sasino97 - 15.05.2014
Recently I learned this
pawn Code:
// I define some values as the powers of 2
#define A 1 // 2^0
#define B 2 // 2^1
#define C 4 // 2^2
#define D 8 // 2^3
#define E 16 // 2^4
#define F 32 // 2^5
#define G 64 // 2^6
#define H 128 // 2^7
#define I 256 // 2^8
// the variable can be one of those values
variable = D;
// but the variable can also be multiple values
variable = F + H; // = 32 + 128 = 160, and there are no other sums of those values that equal 160
variable = A + F + E + H;
// you can check if the variable equals one of the values
if(variable == I)
// you can also check if the variable is the sum of more of these values
if(variable == T + H + C)
// and finally you can also check if the variable's value has one of the values as addend
if(variable & I)
if(variable & B && variable & D)
I think that's very useful, learn and use it (y)
Re: Today I learned - Share your newly found knowledge! -
Y_Less - 15.05.2014
So you learned binary?
Re: Today I learned - Share your newly found knowledge! -
Kyle - 15.05.2014
Quote:
Originally Posted by Y_Less
So you learned binary?
|
I thought binary was 0's and 1's?
Re: Today I learned - Share your newly found knowledge! -
Whitetiger - 15.05.2014
binary IS bits. and he's using the bit operations.
binary is 1's and 0's. bit's are 1's and 0's as well.
Re: Today I learned - Share your newly found knowledge! -
Y_Less - 15.05.2014
Binary is a numerical system based on base-2, bits are a method of storing data, data that is often binary numbers.
Re: Today I learned - Share your newly found knowledge! -
Abagail - 15.05.2014
Today I learned Y_Less is not in-fact a robot. Put this in your signature if you thought he was a robot!
NOTICE: Please don't give me an infraction for this! Cheers!
Re: Today I learned - Share your newly found knowledge! -
Y_Less - 16.05.2014
No, the correct term is "cyborg".