#include #pragma tabsize 0 const Messege = 0xFFFF00AA; enum ColorInfo { COLOR_name[64], COLOR_cmd[32], COLOR_hex } new Colors[][ColorInfo] = { // { "色の名前", "コマンド名", 色id }, {"Black", "black", 0xffffff00}, {"Silver", "silver", 0xfffafa00}, {"Gray", "gray", 0xf8f8ff00}, {"White", "white", 0xfffaf000}, {"Maroon", "maroon", 0xfaf0e600}, {"Red", "red", 0xfaebd700}, {"Purple", "purple", 0xffefd500}, {"Fuchsia", "fuchsia", 0xffebcd00}, {"Green", "green", 0xffe4c400}, {"Lime", "lime", 0xffe4b500}, {"Olive", "olive", 0xffdead00}, {"Yellow", "yellow", 0xffdab900}, {"Navy", "navy", 0xffe4e100}, {"Blue", "blue", 0xfff0f500}, {"Teal", "teal", 0xfff5ee00}, {"Aqua", "aqua", 0xfff5ee00}, {"Orange", "orange", 0xfff5ee00} }; public OnFilterScriptInit() { SendClientMessageToAll(Messege, "Reloading colors.amx..."); return 1; } public OnFilterScriptExit() { SendClientMessageToAll(Messege, "unloaded colors.amx."); return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256]; new idx; cmd = strtok(cmdtext, idx); if (strcmp("/color", cmd, true) == 0) { cmd = strtok(cmdtext, idx); if(!strlen(cmd)) { SendClientMessage(playerid, Messege, " 使い方: /color [カラー名]"); return 1; } if(strlen(cmd)) { // /color [色の名前] for(new i = 0; i < sizeof(Colors); ++i) { if(strcmp(Colors[i][COLOR_cmd], cmd, true) == 0) { Color(playerid, Colors[i][COLOR_hex], Colors[i][COLOR_name]); return 1; } } SendClientMessage(playerid, Messege, " 指定された色は見つかりませんでした。"); return 1; } return 1; } return 0; } stock Color(playerid, color, const title[]) { new message[256]; strcat(message, " 名前の色を"); strcat(message, title); strcat(message, " に変更しました."); SendClientMessageToAll(color, message); SetPlayerColor(playerid, color); return; } 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; }