SA-MP Forums Archive
help with ask/answer - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: help with ask/answer (/showthread.php?tid=89652)



help with ask/answer - WardenCS - 03.08.2009

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;
}




Re: help with ask/answer - xCoder - 03.08.2009

where is error?


Re: help with ask/answer - Correlli - 03.08.2009

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.


Re: help with ask/answer - WardenCS - 04.08.2009

where i gotta add this i dont understand?:S


Re: help with ask/answer - WardenCS - 04.08.2009

sorry for double,but please!


Re: help with ask/answer - Correlli - 04.08.2009

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


Re: help with ask/answer - WardenCS - 04.08.2009

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


Re: help with ask/answer - saiberfun - 04.08.2009

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


Re: help with ask/answer - WardenCS - 04.08.2009

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


Re: help with ask/answer - Correlli - 04.08.2009

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