#define pClass(%1) GetPlayerSkin(playerid)==%1
new plClass = GetPlayerSkin(playerid);
if(plClass == 100 || plClass == 200 || plClass == 300)
if(pClass(100) || pClass(200) || pClass(300))
{
}
Originally Posted by Y_Leѕѕ
You just basically tripled the time that code takes to run!
Also: pawn Код:
pawn Код:
pawn Код:
|
if(pClass(100) || pClass(200) || pClass(300))
{
SendClientMsg...
gTeam...
Originally Posted by ♣ ⓐⓢⓢ
Actually ****** wanted to help you to improve your macro (indirectly)...
|
Originally Posted by Luka™
Quote:
|
Originally Posted by cyber_punk
why would not want to make your code faster/ more efficient :S
|
Originally Posted by Y_Leѕѕ
Quote:
pawn Код:
pawn Код:
pawn Код:
|
new PlayerText3D:playertextid[MAX_PLAYERS]; stock AddTextPlayer3D(playerid,COLOR,text[],Float:Distance) { playertextid[playerid] = PlayerText3D:Create3DTextLabel(text, COLOR, 0.0,0.0,0.0, Distance, 0, 0); Attach3DTextLabelToPlayer(Text3D:playertextid[playerid], playerid, 0.0, 0.0, -0.4); return 1; } stock DeletePlayerText(playerid) { Delete3DTextLabel(Text3D:playertextid[playerid]); return 1; }
public OnPlayerSpawn(playerid) { if(IsPlayerNPC(playerid)) { new playername[64]; GetPlayerName(playerid,playername,64); if(!strcmp(playername,"Mikael",true)) { PutPlayerInVehicle(playerid, Coach1, 0); SetPlayerColor(playerid,COLOR_WHITE); SetPlayerSkin(playerid,16); AddTextPlayer3D(playerid,COLOR_AQUA,"Mikael",40.0); }
stock IsValidEMail(email[])
{
new lenght = strlen(email),
emailsplit[2][MAX_PLAYER_EMAIL],
domainsplit[2][MAX_PLAYER_EMAIL],
atsign;
split(email, emailsplit, '@');
if (strlen(emailsplit[0]) > 0)
{
// Local part (username) is not empty. Continue...
}
else { return 0; } // No need to continue...
split(emailsplit[1], domainsplit, '.');
if (strlen(domainsplit[0]) > 2)
{
// Domain name has 3 or more charaters. Continue...
}
else { return 0; } // No need to continue...
new len = strlen(emailsplit[0]),
doubledot = strfind(emailsplit[0], "..", true);
if ((emailsplit[0][0] == '.') || (emailsplit[0][len - 1] == '.') || (doubledot != -1))
{
return 0; // The dot (.) can't be on the start or on the end of the local part (username) and double dot (..) is not allowed. Return false...
}
for (new i = 0; i < lenght; i++)
{
if (emailsplit[0][i])
{
if ((emailsplit[0][i] >= 'A' && emailsplit[0][i] <= 'Z') || (emailsplit[0][i] >= 'a' && emailsplit[0][i] <= 'z') || (emailsplit[0][i] >= '0' && emailsplit[0][i] <= '9') || (emailsplit[0][i] == '.') || (emailsplit[0][i] == '-') || (emailsplit[0][i] == '_'))
{
// Local part contains characters that are allowed. Continue...
}
else { return 0; } // No need to continue...
}
if (domainsplit[0][i])
{
if ((domainsplit[0][i] >= 'a' && domainsplit[0][i] <= 'z') || (domainsplit[0][i] == '-'))
{
// Domain name contains charaters that are allowed. Continue...
}
else { return 0; } // No need to continue...
}
// This checks that '@' sign is used only one time...
if (email[i] == '@')
{
atsign++;
if (atsign > 1) { return 0; } // No need to continue...
}
}
for (new i = 0; i < MAX_TOPLEVEL_DOMAINS; i++)
{
if (strcmp(domainsplit[1], TopLevelDomains[i], true) == 0)
{
return 1; // All checks are Ok, eMail is valid...
}
}
return 0; // If the inserted Top Level Domain don't match with the TopLevelDomains then return false...
}
forward split(const strsrc[], strdest[][], delimiter);
public split(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while (i <= strlen(strsrc))
{
if (strsrc[i] == delimiter || i == strlen(strsrc))
{
len = strmid(strdest[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
new TopLevelDomains[MAX_TOPLEVEL_DOMAINS][] = {
{"ac"},
{"ad"},
{"ae"},
{"aero"},
{"af"},
{"ag"},
{"ai"},
{"al"},
{"am"},
{"an"},
{"ao"},
{"aq"},
{"ar"},
{"arpa"},
{"as"},
{"asia"},
{"at"},
{"au"},
{"aw"},
{"ax"},
{"az"},
{"ba"},
{"bb"},
{"bd"},
{"be"},
{"bf"},
{"bg"},
{"bh"},
{"bi"},
{"biz"},
{"bj"},
{"bm"},
{"bn"},
{"bo"},
{"br"},
{"bs"},
{"bt"},
{"bv"},
{"bw"},
{"by"},
{"bz"},
{"ca"},
{"cat"},
{"cc"},
{"cd"},
{"cf"},
{"cg"},
{"ch"},
{"ci"},
{"ck"},
{"cl"},
{"cm"},
{"cn"},
{"co"},
{"com"},
{"coop"},
{"cr"},
{"cu"},
{"cv"},
{"cx"},
{"cy"},
{"cz"},
{"de"},
{"dj"},
{"dk"},
{"dm"},
{"do"},
{"dz"},
{"ec"},
{"edu"},
{"ee"},
{"eg"},
{"er"},
{"es"},
{"et"},
{"eu"},
{"fi"},
{"fj"},
{"fk"},
{"fm"},
{"fo"},
{"fr"},
{"ga"},
{"gb"},
{"gd"},
{"ge"},
{"gf"},
{"gg"},
{"gh"},
{"gi"},
{"gl"},
{"gm"},
{"gn"},
{"gov"},
{"gp"},
{"gq"},
{"gr"},
{"gs"},
{"gt"},
{"gu"},
{"gw"},
{"gy"},
{"hk"},
{"hm"},
{"hn"},
{"hr"},
{"ht"},
{"hu"},
{"id"},
{"ie"},
{"il"},
{"im"},
{"in"},
{"info"},
{"int"},
{"io"},
{"iq"},
{"ir"},
{"is"},
{"it"},
{"je"},
{"jm"},
{"jo"},
{"jobs"},
{"jp"},
{"ke"},
{"kg"},
{"kh"},
{"ki"},
{"km"},
{"kn"},
{"kp"},
{"kr"},
{"kw"},
{"ky"},
{"kz"},
{"la"},
{"lb"},
{"lc"},
{"li"},
{"lk"},
{"lr"},
{"ls"},
{"lt"},
{"lu"},
{"lv"},
{"ly"},
{"ma"},
{"mc"},
{"md"},
{"me"},
{"mg"},
{"mh"},
{"mil"},
{"mk"},
{"ml"},
{"mm"},
{"mn"},
{"mo"},
{"mobi"},
{"mp"},
{"mq"},
{"mr"},
{"ms"},
{"mt"},
{"mu"},
{"museum"},
{"mv"},
{"mw"},
{"mx"},
{"my"},
{"mz"},
{"na"},
{"name"},
{"nc"},
{"ne"},
{"net"},
{"nf"},
{"ng"},
{"ni"},
{"nl"},
{"no"},
{"np"},
{"nr"},
{"nu"},
{"nz"},
{"om"},
{"org"},
{"pa"},
{"pe"},
{"pf"},
{"pg"},
{"ph"},
{"pk"},
{"pl"},
{"pm"},
{"pn"},
{"pr"},
{"pro"},
{"ps"},
{"pt"},
{"pw"},
{"py"},
{"qa"},
{"re"},
{"ro"},
{"rs"},
{"ru"},
{"rw"},
{"sa"},
{"sb"},
{"sc"},
{"sd"},
{"se"},
{"sg"},
{"sh"},
{"si"},
{"sj"},
{"sk"},
{"sl"},
{"sm"},
{"sn"},
{"so"},
{"sr"},
{"st"},
{"su"},
{"sv"},
{"sy"},
{"sz"},
{"tc"},
{"td"},
{"tel"},
{"tf"},
{"tg"},
{"th"},
{"tj"},
{"tk"},
{"tl"},
{"tm"},
{"tn"},
{"to"},
{"tp"},
{"tr"},
{"travel"},
{"tt"},
{"tv"},
{"tw"},
{"tz"},
{"ua"},
{"ug"},
{"uk"},
{"us"},
{"uy"},
{"uz"},
{"va"},
{"vc"},
{"ve"},
{"vg"},
{"vi"},
{"vn"},
{"vu"},
{"wf"},
{"ws"},
{"ye"},
{"yt"},
{"yu"},
{"za"},
{"zm"},
{"zw"}
};
#define MAX_PLAYER_EMAIL 128
#define MAX_TOPLEVEL_DOMAINS 269
Originally Posted by Luka™
Is there maybe GetIDFromName or something like that (it should get ID from player nick).
|
stock GetIDFromName(name[])
{
new
i;
for(i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new
playername[MAX_PLAYER_NAME];
GetPlayerName(i, playername, sizeof(playername));
if(strcmp(playername, name, true, strlen(name)) == 0) return i;
}
}
return INVALID_PLAYER_ID;
}
stock IsValidFightingStyle(style)
{
#define MAX_FIGHT_STYLES 6
new fightStyles[MAX_FIGHT_STYLES] =
{
4, 5, 6, 7, 15, 26
};
for (new i = 0; i < MAX_FIGHT_STYLES; i++)
{
if (style == fightStyles[i]) return true;
}
return false;
}
forward IsValidFightingStyle(style);
public IsValidFightingStyle(style)
{
switch(style)
{
case 4,5,6,7,15,26: return 1;
default: return 0;
}
}
Originally Posted by $ЂЯĢ
Why so much complicating?
pawn Код:
|
stock GetPlayersInTeam(teamid)
{
new playersInTeam = 0;
for(new i=0;i<MAX_PLAYERS<i++;)
{
if(IsPlayerConnected(i) && GetPlayerTeam(i) == teamid) playersInTeam++;
}
return playersInTeam;
}
public OnPlayerRequestSpawn(playerid)
{
new pClass = GetPlayerSkin(playerid);
switch(pClass)
{
case 1,2,3: SetPlayerTeam(playerid,1);
case 4,5,6: SetPlayerTeam(playerid,2);
}
if(GetPlayerTeam(playerid) == 1 && GetPlayersInTeam(1) > GetPlayersInTeam(2))
{
SendClientMessage(playerid,color,"Team 1 is full, please choose another team/skin/class.");
return 0;
}
else if(GetPlayerTeam(playerid) == 2 && GetPlayersInTeam(1) < GetPlayersInTeam(2))
{
SendClientMessage(playerid,color,"Team 2 is full, please choose another team/skin/class.");
return 0;
}
return 1;
}
Originally Posted by Haly11
ok if i ask a samp player to do that how u thing will be i try to use C++ to make the game mod
|
stock IsBotName(playerid, Name[]) { new Bot[MAX_PLAYER_NAME]; GetPlayerName(playerid, Bot, sizeof(Bot)); if(!strcmp(Bot, Name, true)) return 1; return 0; }
public OnPlayerSpawn(playerid) { if(IsPlayerNPC(playerid)) { if(IsBotName(playerid, "Doctor")) { SetPlayerSkin(playerid, 70); } return 1; } return 1; }