admin | Дата: Вторник, 21.12.2010, 17:08:28 | Сообщение # 1 |
Группа: Администраторы
Сообщений: 3869
| Два мини-урока (По надобности) 1.Включение & Выключение под одной командой Code
#include <a_samp> // что new OnOff[MAX_PLAYERS]; // начинаем public OnPlayerCommandText(playerid,cmdtext[]) { new idx; new cmd[256]; cmd = strtok(cmdtext, idx); // комманда if(strcmp(cmd, "/действие", true) == 0) { // включится if (OnOff[playerid] == 0) { SendClientMessage(playerid,0xAAEEAEA , "Вы включили что-то."); OnOff[playerid] = 1; } // выключится else if (OnOff[playerid] == 1) { SendClientMessage(playerid, 0xAAEEAEA, "Вы выключили что-то."); OnOff[playerid] = 0; } } return 1; } // для работы 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; } 2 Команда с пробелом и переменной Code
#include <a_samp> // начинаем public OnPlayerCommandText(playerid,cmdtext[]) { new idx; new cmd[256]; cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/action", true) == 0) { if(IsPlayerConnected(playerid)) { new act[64]; act = strtok(cmdtext, idx); if(!strlen(act)) { SendClientMessage(playerid, 0xAEAEAA, "Помощь: /action [Наименование]"); SendClientMessage(playerid, 0xAEAEAA, "Наименования: aa, ab, ac, ad, ae"); return 1; } if(strcmp(act,"aa",true) == 0) { SendClientMessage(playerid, 0xAEAEAA, "Вы получили a-a ! 'A' "); return 1; } else if(strcmp(act,"ab",true) == 0) { SendClientMessage(playerid, 0xAEAEAA, "Вы получили a-b ! 'B'"); return 1; } else if(strcmp(act,"ac",true) == 0) { SendClientMessage(playerid, 0xAEAEAA, "Вы получили a-c ! 'C'"); return 1; } else if(strcmp(act,"ad",true) == 0) { SendClientMessage(playerid, 0xAEAEAA, "Вы получили a-d ! 'D'"); return 1; } else if(strcmp(act,"ae",true) == 0) { SendClientMessage(playerid, 0xAEAEAA, "Вы получили a-e ! 'E'"); return 1; } else { SendClientMessage(playerid, 0xAEAEAA, "Помощь: /action [Наименование]"); SendClientMessage(playerid, 0xAEAEAA, "Наименования: aa, ab, ac, ad, ae"); } } } return 1; } // для работы Code 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; } Конец Источник:forum.pawno.ru Автор:не помню точна найдете)
zm-jail.ru Разработка сайта samp-pawno.ru
|
|
|
|
|