11.04.2010, 00:25
Here.
the ask commands wich players can use it , /ask:
and the admins can answer the question with this command " /ans(wer)
the ask commands wich players can use it , /ask:
Код:
//-------------------------[Ask]--------------------------------------------- if(strcmp(cmd, "/ask", true) == 0) { GetPlayerName(playerid, sendername, sizeof(sendername)); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[64]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ask [question]"); return 1; } format(string, sizeof(string), "%s (id%d) asks %s", sendername, playerid, result); ABroadCast(COLOR_YELLOW,string,1); SendClientMessage(playerid, COLOR_GRAD2, "Your question has been sent, please wait a response"); }
Код:
//-------------------------[Answer]--------------------------------------------- if((strcmp(cmd, "/answer", true) == 0 || strcmp(cmd, "/ans", true) == 0)) { if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pRealAdmin] == 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /ans(wer) [playerid/PartOfName] [Answer]"); return 1; } if(IsStringAName(tmp)) { giveplayerid = GetPlayerID(tmp); } else { giveplayerid = strval(tmp); } if (!IsPlayerConnected(giveplayerid)) { SendClientMessage(playerid, COLOR_RED, "ERROR: That player is not connected!"); return 1; } GetPlayerName(playerid, sendername, sizeof(sendername)); GetPlayerName(giveplayerid, giveplayer, sizeof(sendername)); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[128]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ans(wer) [playerID/PartOfName] [Answer]"); return 1; } format(string, sizeof(string), "Admin %s (%d) has Answered to your question with the following answer:", sendername, playerid); SendClientMessage(giveplayerid, COLOR_YELLOW, string); format(string, sizeof(string), "%s", result); SendClientMessage(giveplayerid, COLOR_YELLOW, string); format(string, sizeof(string), "Admin %s has responded to %s [ID:%d]'s Question", sendername, giveplayer, giveplayerid); ABroadCast(COLOR_GREEN, string,1); } }