Originally Posted by PT
A usar sscanf e depois aparassem comados assim:
pawn Код:
CMD:pinfo(playerid, params[]) { if(pAdmin[playerid][Level] >= 1) return SendClientMessage(playerid, -1, "Vocк nгo й um Administrador"); new tmp[256], idx, string[128]; tmp = strtok(params, idx); new id; if(!IsNumeric(tmp)) id = ReturnPlayerID(tmp); else id = strval(tmp); if(!strlen(tmp)) return SendClientMessage(playerid, -1, "Uso: /pinfo [id]"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "ID invбlido!"); format(string, sizeof(string), "|__________ Informaзхes de %s __________|", GetName(id)); SendClientMessage(playerid, -1,string); new ip[24]; new Float:health; new Float:armour; new ammo = GetPlayerAmmo(id); new ping = GetPlayerPing(id); new money = GetPlayerMoney(id); new level = GetPlayerScore(id); GetPlayerHealth(id,health); GetPlayerArmour(id,armour); GetPlayerIp(id, ip, sizeof ip); format(string, sizeof(string), "IP: %s", ip); SendClientMessage(playerid, -1,string); format(string, sizeof(string), "Level: %d", level); SendClientMessage(playerid, -1,string); format(string, sizeof(string), "Vida: %.1f", health); SendClientMessage(playerid, -1,string); format(string, sizeof(string), "Colete: %.1f", armour); SendClientMessage(playerid, -1,string); format(string, sizeof(string), "Muniзгo da arma na mгo: %d", ammo); SendClientMessage(playerid, -1,string); format(string, sizeof(string), "Ping: %d", ping); SendClientMessage(playerid, -1,string); format(string, sizeof(string), "Dinheiro: %d", money); SendClientMessage(playerid, -1,string); return 1; }
prox atualizacao, nao precisa:
pawn Код:
strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; } stock strtok2(const string[], &index) { new lenGT = strlen(string); while ((index < lenGT) && (string[index] <= ' ')) { index++; } new offset = index; new result[70]; while ((index < lenGT) && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; } stock ReturnPlayerID(PlayerName[]) { new found=0, id; for(new i=0; i <= MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { new foundname[MAX_PLAYER_NAME+1]; GetPlayerName(i, foundname, MAX_PLAYER_NAME+1); new namelen = strlen(foundname); new bool:searched=false; for(new pos=0; pos <= namelen; pos++) { if(searched != true) { if(strfind(foundname,PlayerName,true) == pos) { found++; id = i; } } } } } if(found == 1) return id; else return INVALID_PLAYER_ID; }
estude os especificadores da sscanf e entendera o que quero dizer.
pra que isto:
pawn Код:
stock GetLevelAdmin(levelid) { new str[50]; if(levelid == 1) { str = "1"; } else if (levelid == 2) { str = "2"; } else if (levelid == 3) { str = "3"; } else if (levelid == 4) { str = "4"; } else if (levelid == 5) { str = "5"; } return str; }
??
pawn Код:
CMD:comandosadmin(playerid) { new dialogrande[1024]; format(dialogrande, sizeof(dialogrande),"%s%s",dialogrande,"/asay, /jetpack, /tr, /ir, /vidat, /dararma, /kick, /pinfo, /setadmin, /ban, /vida, /congelar, /descongelar, /olhar, /olharoff\n"); return 1; }
aconselho vivamente a comecar a otimizar seus scripts.
|