help with ask/answer
#1

hello,i got 2 commands ,one is /ask and one is /answer,how i can make answer for admins and how i can make ask that only admins see it?
please help THANKS




Quote:

if(strcmp(cmd, "/ask", true) == 0)
{
if(IsPlayerConnected(playerid))
{
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 asks : %s", sendername, (result));
ABroadCast(COLOR_YELLOW,string,1);
SendClientMessage(playerid, COLOR_YELLOW, "Your Question Message was sent to the Admins.");
}
return 1;
}
if(strcmp(cmd, "/answer", true) == 0 || strcmp(cmd, "/ans", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/ans)wer [playerid/PartOfName] [Answer]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_GREY, " You can't answer yourself");
}
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: (/ans)wer [playerid/PartOfName] [Answer]");
return 1;
}
format(string, sizeof(string), "%s answers: %s", sendername, (result));
SendClientMessage(giveplayerid, COLOR_GREEN, string);
format(string, sizeof(string), "Answer sent to %s.", giveplayer);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}
}
else
{
format(string, sizeof(string), " %d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}

Reply
#2

where is error?
Reply
#3

Quote:
Originally Posted by Joker_EST
hello,i got 2 commands ,one is /ask and one is /answer,how i can make answer for admins and how i can make ask that only admins see it?
please help THANKS
Use IsPlayerAdmin check.
Reply
#4

where i gotta add this i dont understand?:S
Reply
#5

sorry for double,but please!
Reply
#6

You have an example at wiki page: https://sampwiki.blast.hk/wiki/IsPlayerAdmin
Reply
#7

but if i add it up to that command it will command for admins and ask isnt for admins:S
and i want that admins only see ask?please
Reply
#8

Quote:
Originally Posted by Joker_EST
but if i add it up to that command it will command for admins and ask isnt for admins:S
and i want that admins only see ask?please
make a for loop that checks the admins online and only send em a message
https://sampwiki.blast.hk/wiki/Loop
Reply
#9

dont understand im beginner can u make that cmds ready for me kewl man?
Reply
#10

Quote:
Originally Posted by Joker_EST
dont understand im beginner can u make that cmds ready for me kewl man?
Then you will never learn anything and you'll keep asking for code.
http://forum.sa-mp.com/index.php?topic=2750.0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)