Quote:
Originally Posted by DraKoN
@JatoDie
Use Macro
pawn Код:
#define PlayerExecute(playerid,%2) if(%2[0] == '/') OnPlayerText(playerid,%2)
|
With this I can't use return PlayerExecute(...);
Quote:
Originally Posted by DraKoN
@MenaceX:
pawn Код:
PlayerName(playerid) { new n[24]; GetPlayerName(playerid,n,24); for(new i=0,j = strlen(n); i <= j;++i) if(n[i]=='_') n[i]=' '; return n; }
Otimize Your Loop ¬¬
|
You got worse this function. If you both use 24, SA:MP can change the max player name. If you use strlen, you're using two loops, bacause strlen is actually a loop. If you put it in a variable, it gets worse, because you create one more variable.
pawn Код:
PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof name);
for(new i = 0; name[0]; ++i)
if(name[i] == '_')
n[i] = ' ';
return n;
}
Quote:
Originally Posted by DraKoN
@Hiddos
pawn Код:
public OnGameModeInit() { SetTimer("JPD",7500,true); return 1; } forward JPD(); public JPD() { for(new i, j = MAX_PLAYERS; i < j ; ++ i) { if(IsPlayerConnected(i) && GetPlayerSpecialAction(i) == 2) { //Do your thing } } return 1; }
|
You're creating two variables at this loop, and one of them is defined with a constant: USELESS. for(new i = 0; i < MAX_PLAYERS; ++i) is still better.
And why using IsPlayerConnected? GetPlayerSpecialAction won't return 2 when a player isn't connected, duh. And remember that you have a constant defining the special action 2, in case that SA:MP changes it.
Quote:
Originally Posted by DraKoN
No Called Functions ¬¬
Use:
pawn Код:
stock TagDetect(playerid) { new string[MAX_PLAYER_NAME]; GetPlayerName(playerid, tring,MAX_PLAYER_NAME);//No Use sizeof (called function) if(string[0] == '[' > string[0] == ']') return 1;//No Use strfind (called function) else return 0; }
|
sizeof ISN'T a function, it's an operator. PAWN compiler will optimize it to 24 anyway. And how can you use two operators comparing the same operation? This won't even work. string[0] is the first cell, duh.
Quote:
Originally Posted by DraKoN
Final:
pawn Код:
stock RetireTag(playerid) { new string[MAX_PLAYER_NAME]; GetPlayerName(playerid, tring,MAX_PLAYER_NAME);//No Use sizeof (called function) if(string[0] == '[' && string[0] == ']') { strdel(name, string[0] == '[', string[0] == ']' + 1); if(string[0]) { SetPlayerName(playerid, name); } } }
|
And the sizeof operator again...
And the string[0] thing again... how can string[0] can hold a '[' and a ']' at the same time?
"string[0] == '['" will return a boolean value. strdel uses a integer value.
Quote:
Originally Posted by DraKoN
Or
pawn Код:
new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof name); new startpos = strfind(name, "[", true), endpos = strfind(name, "]", true); if(startpos != -1 && endpos != -1) { strdel(name, startpos, endpos + 1); if(name[0]) { SetPlayerName(playerid, name); } }
|
Your indentation sucks.
Learn the programming language first before trying to correct others. You're being so lame.