Re: Today I learned - Share your newly found knowledge! - Patrick - 22.10.2013
Today, I learnt that
This Current Code, can be used in opposite ways (I don't know how it is called, but I'll call it, Opposite Function :P)
pawn Код:
new
PlayerTeam [ MAX_PLAYERS char ]
;
//Normal Function
if(PlayerTeam{playerid} == 1)
{
Rest Of The Code In Here
}
//Opposite Function
if(1 == PlayerTeam{playerid})
{
Rest Of The Code In Here
}
Re: Today I learned - Share your newly found knowledge! -
kaisersouse - 22.10.2013
Today I learned that MySQL strict mode requires you update all fields in a query, or have a default values in place for the fields you aren't updating. Otherwise...anger occurs.
Thanks KingJ!
Re: Today I learned - Share your newly found knowledge! -
Slice - 23.10.2013
Quote:
Originally Posted by pds2k12
Today, I learnt that
This Current Code, can be used in opposite ways (I don't know how it is called, but I'll call it, Opposite Function :P)
pawn Код:
new PlayerTeam [ MAX_PLAYERS char ] ;
//Normal Function if(PlayerTeam{playerid} == 1) { Rest Of The Code In Here }
//Opposite Function if(1 == PlayerTeam{playerid}) { Rest Of The Code In Here }
|
They're called
Yoda conditions!
Re: Today I learned - Share your newly found knowledge! -
Pottus - 23.10.2013
Quote:
Originally Posted by Slice
|
Yes master.
Re: Today I learned - Share your newly found knowledge! -
Misiur - 23.10.2013
Highly encouraged in languages without "possible unintended assignment" warnings
Re: Today I learned - Share your newly found knowledge! -
RajatPawar - 23.10.2013
TIL that having spaces before and after a color code in a textdraw can seriously mess up your server and even crash it! Is it a fact or just me?
Also, TIL that the C++ taught in college is seriously outdated, modern C++ is like a new language itself, I got lost in a matter of seconds! (Vectors, STL, containers, etc?) No modest documentation, only big big words.
Re: Today I learned - Share your newly found knowledge! -
-=Dar[K]Lord=- - 23.10.2013
Today i learned how to detect a word from a single character for example...
If Player Abuses using the world "fuck". Then Using A "for" loop we can loop through the string lenght of players text and detect if theres a word 'f' and if yes detect if the words position + 1 is 'u' again check if position of f + 2 is 'u' and position of word + 3 is 'k' using LOGICAL AND..
Like
pawn Код:
public OnPlayerText(playerid,text[])
{
for(new i = 0; i <= strlen(text); i++)
{
if(text[i] == 'f' && text[i+1] == 'u' && text[i+2] == 'c' && text[i+3] == 'k') // Do Something
}
return 1;
}
Well this is the longest way to detect a abusive word in players text but might be usefull to detect correct abusive words in the chat
Re: Today I learned - Share your newly found knowledge! -
Sublime - 26.10.2013
Quote:
Originally Posted by pds2k12
People these days, at least he learnt something, unlike other people who doesn't learn and always ask question(spamming) on Scripting Help
|
Quote:
Originally Posted by Tropicali
Today I learned a few things about 3DTextLabels and inputtext.
|
Words are words, rules are rules
Re: Today I learned - Share your newly found knowledge! -
Tropicali - 27.10.2013
Well I learned how to create a custom 3DTextLabel with dynamic colours and a customised name through a dialog-based system using inputtext and custom colors.
Re: Today I learned - Share your newly found knowledge! -
newbie scripter - 31.10.2013
Today i learned About Enums and isnull, isnull is used to check if is nothing params of a cmd or to check whether smthing is typed. Enum are used to store hugr amount of data.
with this code
pawn Код:
if( isnull (params) ) // for ISNULL
/* ---------------------------------------------------- */
enum whattolearn
{
english,
pawnlanguage,
martianlanguage,
badlanguage
};
new lang [] [whattolearn]
/* don't try my ENUM example :P */
Re: Today I learned - Share your newly found knowledge! -
Ada32 - 31.10.2013
Quote:
Originally Posted by newbie scripter
or to check whether smthing is typed.
|
isnull is used to check for empty strings.
Quote:
Originally Posted by newbie scripter
Enum are used to store hugr amount of data.
|
NO. variables store data. the 'new' keyword creates a variable. enums define a list of symbolic constants.
Re: Today I learned - Share your newly found knowledge! -
whatthefuck123 - 02.11.2013
ok... did anyone learn anything useful today?
i learn that there is a lot to be learned about pawn and scripting in general
Re: Today I learned - Share your newly found knowledge! -
Albright - 03.11.2013
Today, I learned about string formatting, local & global variables and a bit of stocks.
AW: Today I learned - Share your newly found knowledge! -
IPrototypeI - 03.11.2013
Today i learned how to create a map location mover and to rotate to hole map
[ame]http://www.youtube.com/watch?v=U8_4bG8bU6I[/ame]
Re: Today I learned - Share your newly found knowledge! -
whatthefuck123 - 03.11.2013
wtf^? u just attach all objects? and what is the point of this
Re: Today I learned - Share your newly found knowledge! -
Pottus - 05.11.2013
Not bad, next step customize your rotation node
Re: Today I learned - Share your newly found knowledge! -
LeeXian99 - 05.11.2013
I learned how to use SetTimer properly. (but still have a mistake)
pawn Код:
forward ResetRob(playerid);
public ResetRob(playerid)
{
RecentRob[playerid] = 0;
RecentRobbed[playerid] = 0;
}
pawn Код:
CMD:robplayer(playerid,params[])
{
if(gTeam[playerid] != CIVILIAN)
{
SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob players as officer!");
return 1;
}
else if (gTeam[playerid] == CIVILIAN)
{
new targetid,targetname[25],playername[25],Float:X, Float:Y, Float:Z;
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, -1, "{ffff00}=USAGE=: {ffffff}/robplayer <id>");
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}The player is not online!");
if(targetid == playerid) return SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob yourself, idiot.");
if(GetPlayerState(targetid) == PLAYER_STATE_DRIVER || GetPlayerState(targetid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{ff0000}=ERROR=: {ffffff}You can't rob a player that is in a vehicle!");
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{ff0000}=ERROR=: {ffffff}You can't rob when you're in a vehicle, exit your vehicle first!");
if(targetid != IsPlayerInRangeOfPoint(playerid, 4, X, Y, Z)) SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob this player as you're too far than the player!");
GetPlayerPos(targetid, X, Y, Z);
GetPlayerName(targetid, targetname, sizeof(targetname));
GetPlayerName(playerid, playername, sizeof(playername));
if(IsPlayerInRangeOfPoint(targetid, 4, X,Y,Z))
{
if(GetPlayerMoney(targetid) <= 2500 || RecentRobbed[targetid] == 1 || RecentRob[playerid] == 1)
{
SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob this player as the player's cash is less than $2500 or he's recently robbed!");
return 0;
}
else if(GetPlayerMoney(targetid) > 2500 && RecentRobbed[targetid] == 0 || RecentRob[playerid] == 0)
{
new string[128];
new Money = GetPlayerMoney(targetid);
new Robbed = random(Money);
GivePlayerMoney(playerid, Robbed);
GivePlayerMoney(targetid, -Robbed);
format(string, sizeof(string), "{ffff00}=SUCCESS=: {ffffff}You have robbed %d from %s!", Robbed, targetname);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "{ffff00}=SUCCESS=: {ffffff}%s has robbed %d from you!", playername, Robbed);
SendClientMessage(targetid, -1, string);
RecentRobbed[targetid] = 1;
RecentRob[playerid] = 1;
UserInfo[playerid][uRobbed]++;
SetTimer("ResetRob", 5*60*1000, 0);
return 1;
}
}
}
return 1;
}
Just sayin'. Take this script if you want my shitty script.
Re: Today I learned - Share your newly found knowledge! -
CrazyChoco - 05.11.2013
Quote:
Originally Posted by LeeXian99
I learned how to use SetTimer properly. (but still have a mistake)
pawn Code:
forward ResetRob(playerid); public ResetRob(playerid) { RecentRob[playerid] = 0; RecentRobbed[playerid] = 0; }
pawn Code:
CMD:robplayer(playerid,params[]) { if(gTeam[playerid] != CIVILIAN) { SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob players as officer!"); return 1; } else if (gTeam[playerid] == CIVILIAN) { new targetid,targetname[25],playername[25],Float:X, Float:Y, Float:Z; if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, -1, "{ffff00}=USAGE=: {ffffff}/robplayer <id>"); if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}The player is not online!"); if(targetid == playerid) return SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob yourself, idiot."); if(GetPlayerState(targetid) == PLAYER_STATE_DRIVER || GetPlayerState(targetid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{ff0000}=ERROR=: {ffffff}You can't rob a player that is in a vehicle!"); if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{ff0000}=ERROR=: {ffffff}You can't rob when you're in a vehicle, exit your vehicle first!"); if(targetid != IsPlayerInRangeOfPoint(playerid, 4, X, Y, Z)) SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob this player as you're too far than the player!"); GetPlayerPos(targetid, X, Y, Z); GetPlayerName(targetid, targetname, sizeof(targetname)); GetPlayerName(playerid, playername, sizeof(playername)); if(IsPlayerInRangeOfPoint(targetid, 4, X,Y,Z)) { if(GetPlayerMoney(targetid) <= 2500 || RecentRobbed[targetid] == 1 || RecentRob[playerid] == 1) { SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob this player as the player's cash is less than $2500 or he's recently robbed!"); return 0; } else if(GetPlayerMoney(targetid) > 2500 && RecentRobbed[targetid] == 0 || RecentRob[playerid] == 0) { new string[128]; new Money = GetPlayerMoney(targetid); new Robbed = random(Money); GivePlayerMoney(playerid, Robbed); GivePlayerMoney(targetid, -Robbed); format(string, sizeof(string), "{ffff00}=SUCCESS=: {ffffff}You have robbed %d from %s!", Robbed, targetname); SendClientMessage(playerid, -1, string); format(string, sizeof(string), "{ffff00}=SUCCESS=: {ffffff}%s has robbed %d from you!", playername, Robbed); SendClientMessage(targetid, -1, string); RecentRobbed[targetid] = 1; RecentRob[playerid] = 1; UserInfo[playerid][uRobbed]++; SetTimer("ResetRob", 5*60*1000, 0); return 1; } } } return 1; }
Just sayin'. Take this script if you want my shitty script.
|
Instead of creating timer for each function make a global one, which contains everything.
Re: Today I learned - Share your newly found knowledge! -
IPrototypeI - 05.11.2013
Quote:
Originally Posted by whatthefuck123
wtf^? u just attach all objects? and what is the point of this
|
The point of this was not how to rotate the Objects, but rather to save all coords of this Objects.
Re: Today I learned - Share your newly found knowledge! -
DanishHaq - 05.11.2013
Quote:
Originally Posted by LeeXian99
I learned how to use SetTimer properly. (but still have a mistake)
pawn Code:
forward ResetRob(playerid); public ResetRob(playerid) { RecentRob[playerid] = 0; RecentRobbed[playerid] = 0; }
pawn Code:
CMD:robplayer(playerid,params[]) { if(gTeam[playerid] != CIVILIAN) { SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob players as officer!"); return 1; } else if (gTeam[playerid] == CIVILIAN) { new targetid,targetname[25],playername[25],Float:X, Float:Y, Float:Z; if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, -1, "{ffff00}=USAGE=: {ffffff}/robplayer <id>"); if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}The player is not online!"); if(targetid == playerid) return SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob yourself, idiot."); if(GetPlayerState(targetid) == PLAYER_STATE_DRIVER || GetPlayerState(targetid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{ff0000}=ERROR=: {ffffff}You can't rob a player that is in a vehicle!"); if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{ff0000}=ERROR=: {ffffff}You can't rob when you're in a vehicle, exit your vehicle first!"); if(targetid != IsPlayerInRangeOfPoint(playerid, 4, X, Y, Z)) SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob this player as you're too far than the player!"); GetPlayerPos(targetid, X, Y, Z); GetPlayerName(targetid, targetname, sizeof(targetname)); GetPlayerName(playerid, playername, sizeof(playername)); if(IsPlayerInRangeOfPoint(targetid, 4, X,Y,Z)) { if(GetPlayerMoney(targetid) <= 2500 || RecentRobbed[targetid] == 1 || RecentRob[playerid] == 1) { SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob this player as the player's cash is less than $2500 or he's recently robbed!"); return 0; } else if(GetPlayerMoney(targetid) > 2500 && RecentRobbed[targetid] == 0 || RecentRob[playerid] == 0) { new string[128]; new Money = GetPlayerMoney(targetid); new Robbed = random(Money); GivePlayerMoney(playerid, Robbed); GivePlayerMoney(targetid, -Robbed); format(string, sizeof(string), "{ffff00}=SUCCESS=: {ffffff}You have robbed %d from %s!", Robbed, targetname); SendClientMessage(playerid, -1, string); format(string, sizeof(string), "{ffff00}=SUCCESS=: {ffffff}%s has robbed %d from you!", playername, Robbed); SendClientMessage(targetid, -1, string); RecentRobbed[targetid] = 1; RecentRob[playerid] = 1; UserInfo[playerid][uRobbed]++; SetTimer("ResetRob", 5*60*1000, 0); return 1; } } } return 1; }
Just sayin'. Take this script if you want my shitty script.
|
It's not this:
pawn Code:
SetTimer("ResetRob", 5*60*1000, 0);
It's this:
pawn Code:
SetTimerEx("ResetRob", 5*60*1000, false, "i", playerid);
SetTimerEx will forward it if it has any variables within the brackets, forgot how to phrase this.
pawn Code:
forward ResetRob(); // this would use SetTimer
forward ResetRob(playerid); // this would use SetTimerEx