SA-MP Forums Archive
Disable Teleport command help. - 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: Disable Teleport command help. (/showthread.php?tid=89567)



Disable Teleport command help. - BP13 - 02.08.2009

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.


Re: Disable Teleport command help. - whooper - 02.08.2009

wow nice idea.


Re: Disable Teleport command help. - yezizhu - 03.08.2009

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



Re: Disable Teleport command help. - BP13 - 03.08.2009

umm that still does not work


Re: Disable Teleport command help. - yezizhu - 03.08.2009

Please show new code


Re: Disable Teleport command help. - BP13 - 03.08.2009

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


Re: Disable Teleport command help. - yezizhu - 03.08.2009

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


Re: Disable Teleport command help. - ruarai - 03.08.2009

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



Re: Disable Teleport command help. - yezizhu - 03.08.2009

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