Disable Teleport command help.
#1

hi I need a /teleon and /teleoff command. this is what I have so far.


new bool: ReceiveInfo[MAX_PLAYERS];


dcmd_skroad(playerid, params[])
{
#pragma unused params
SetPlayerInterior(playerid, 0);
ResetPlayerWeapons(playerid);
SetPlayerPos(playerid,3893.8152, -1623.4252, 1442.5);
GameTextForPlayer(playerid,"SKROAD",2500,3);
CallRemoteFunction("XDynUpdateStart", "i", playerid);
SetCameraBehindPlayer(playerid);
///////////////////////////////
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(ReceiveInfo[i] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "TELE: %s has gone to Skroad (/skroad)", pName);
SendClientMessageToAll(COLOR_YELLOW, string);
}
}
}
}
...
if(strcmp(cmdtext, "/teleon", true) == 0)
{
if(ReceiveInfo[playerid] == false)
{
ReceiveInfo[playerid] = true;
SendClientMessage(playerid, COLOR_BASIC, "Now you will receive teleports of other players.");
PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You already receive teleports!!");
}
return 1;
}
if(strcmp(cmdtext, "/teleoff", true) == 0)
{
if(ReceiveInfo[playerid] == true)
{
ReceiveInfo[playerid] = false;
SendClientMessage(playerid, COLOR_BASIC, "Now you won't receive teleports.");
PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You already don't receive teleports!");
}
return 1;
}

when I do /teleon and /teleoff and try it it does work but when Receiveinfo is 0 after typing /teleoff it does not show that you teleported somewhere and it appears that everything worked. but it says Server Unknown Command. even though it worked.
Reply
#2

wow nice idea.
Reply
#3

It's not necessary to tell player that he has already en/diableed the tele request, try to remove if(RecieceInfo[playerid] == true or false), and the brackets needed by them.
BTW, that's really nice idea,I'll "steal" it : P
Reply
#4

umm that still does not work
Reply
#5

Please show new code
Reply
#6

what new code? The one I posted is not working and explained.
Reply
#7

I can't find any poblem from your comannd o.0
Reply
#8

Quote:

if(ReceiveInfo[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "TELE: %s has gone to Skroad (/skroad)", pName);
SendClientMessage(i,COLOR_YELLOW, string);
}

you forgot a [playerid] after ReceiveInfo
and you also send the message to all players even though the player has done /teleoff
Reply
#9

Quote:
Originally Posted by ruarai
Quote:

if(ReceiveInfo[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "TELE: %s has gone to Skroad (/skroad)", pName);
SendClientMessage(i,COLOR_YELLOW, string);
}

you forgot a [playerid] after ReceiveInfo
and you also send the message to all players even though the player has done /teleoff
That's not the reason that causes UnknownCommand
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)