How to return an error message? - 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: How to return an error message? (
/showthread.php?tid=195904)
How to return an error message? -
grand.Theft.Otto - 04.12.2010
I have a /stadium command at the moment that teleport's to 17 different DM spots, but when someone types /stadium alone, I want it to return an error saying:
How can I do that?
This is what I have at the moment:
pawn Код:
if(!strcmp(cmdtext,"/stadium 17",true))
{
SetPlayerPos(playerid,593.0692,-2433.1682,46.8059);
SendClientMessage(playerid,0x33CCFFAA,"WELCOME - Teleported To Deathmatch Stadium 17.");
new string[128];
new playername[MAX_PLAYER_NAME]; GetPlayerName(playerid,playername,sizeof(playername));
format(string, sizeof(string),"%s (%d) Has Teleported To Stadium 17. (/stadium 17)",playername,playerid); SendClientMessageToAll(COLOR_PINK,string);
return 1;
Thanks
Re: How to return an error message? -
Rudyy - 04.12.2010
pawn Код:
if(!strcmp(cmdtext,"/stadium", true))
{
new tmp[256];
tmp = strtok(cmdtext, idx);
new stadiumid = strval(tmp);
if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /stadium [1-17]");
if(stadiumid > 17 || stadium < 1) return SendClientMessage(playerid,COLOR_RED,"USAGE: /stadium [1-17]");
if(stadiumid == 1)
{
// if they type stadium 1
}
if(stadiumid == 2)
{
//stadium 2
}
if(stadiumid == 3)
{
//stadium 3
}
if(stadiumid == 4)
{
//stadium 4
}
if(stadiumid == 5)
{
//stadium 5
}
if(stadiumid == 6)
{
//stadium 6
}
if(stadiumid == 7)
{
//stadium 7
}
if(stadiumid == 8)
{
//stadium 8
}
if(stadiumid == 9)
{
//stadium 9
}
if(stadiumid == 10)
{
//stadium 10
}
if(stadiumid == 11)
{
//stadium 11
}
if(stadiumid == 12)
{
//stadium 12
}
if(stadiumid == 13)
{
//stadium 13
}
if(stadiumid == 14)
{
//stadium 14
}
if(stadiumid == 15)
{
//stadium 15
}
if(stadiumid == 16)
{
//stadium 16
}
if(stadiumid == 17)
{
//stadium 17
SetPlayerPos(playerid,593.0692,-2433.1682,46.8059);
SendClientMessage(playerid,0x33CCFFAA,"WELCOME - Teleported To Deathmatch Stadium 17.");
new string[128];
new playername[MAX_PLAYER_NAME]; GetPlayerName(playerid,playername,sizeof(playername));
format(string, sizeof(string),"%s (%d) Has Teleported To Stadium 17. (/stadium 17)",playername,playerid); SendClientMessageToAll(COLOR_PINK,string);
}
return 1;
}
Re: How to return an error message? -
dice7 - 04.12.2010
You don't have to return a function call, you can also do like this (example from the upper code)
pawn Код:
if(!strlen(tmp))
{
//some format function
SendClientMessage(playerid,COLOR_RED,"USAGE: /stadium [1-17]");
return 1;
}