27.03.2011, 07:20
Hi all! I am not new now in the scripting hobby, so I think I should try different ways to script. Have a look at this command:
No errors when I compile! Yeah, I know, the right way:
But I tried the other way. Now, my question is:
1) Should the first way work IG?!
2) What way should I use to compile? I am for the first one. Dunno why, it seems more professional
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(sethealth, 9, cmdtext);
return 1;
}
dcmd_sethealth(playerid, params[]) {
new pID, value;
if(sscanf(params, "ui", pID, value)) {
if(PlayerInfo[playerid][AdminLevel] >= 3) {
if(pID != INVALID_PLAYER_ID) {
new tName[MAX_PLAYER_NAME], string[128];
GetPlayerName(pID, tName, MAX_PLAYER_NAME);
format(string, sizeof(string), "You have set (%i) %s's health to %i", pID, tName, value);
SetPlayerHealth(pID, value);
}
else return SendClientMessage(playerid, COLOR_GREEN, "Player Not Found");
}
else return SendClientMessage(playerid, COLOR_RED, "You have no acces to this command");
}
return SendClientMessage(playerid, COLOR_GOLD, "Syntax Error: /sethealth [playerid] [amount]");
}
pawn Код:
dcmd_sethealth(playerid, params[]) {
new pID, value, pName[MAX_PLAYER_NAME], string[128];
if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COLOR_GOLD, "/sethealth [playerid] [amount]");
else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREEN, "Player Not Found");
else if(PlayerInfo[playerid][AdminLevel] <= 3) return SendClientMessage(playerid, COLOR_RED, "You have no access to this command");
else {
SetPlayerHealth(playerid, value);
GetPlayerName(pID, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "You changed (%i) %s's health to %i", pID, pName, value);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
return 1;
}
1) Should the first way work IG?!
2) What way should I use to compile? I am for the first one. Dunno why, it seems more professional