#1

I have used this code to make /go command with /gos command that enables/disables another players from teleporting to you but if i type /gos it always enable and don't disable so players can tele to me always!
(it compiles without any error)
please help me!
Thanks!
Код:
CMD:go(playerid, params[])
{
	new giveplayerid;
	if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE:/go(playerid) to teleport to that player");
	new Float:x;
	new Float:y;
	new Float:z;
	if(Goto == 1)
	{
		GetPlayerPos(giveplayerid, x,y,z);
		SetPlayerPos(playerid, x,y,z);
	}
	else if(Goto == 0)
	{
	    SendClientMessage(playerid, 0xFF0000FF, "That player disabled teleports to him!");
	}
	return 1;
}

CMD:gos(playerid, params[])
{
	if(Goto == 1)
	{
	    SendClientMessage(playerid, 0xFF0000FF, "You have disabled player from teleporting to you!");
	    Goto = 0;
	}
	if(Goto == 0)
	{
	    SendClientMessage(playerid, 0xFF0000FF, "You have enabled player from teleporting to you!");
	    Goto = 1;
	}
	return 1;
}
Reply
#2

Quote:
Originally Posted by ironmen
Посмотреть сообщение
I have used this code to make /go command with /gos command that enables/disables another players from teleporting to you but if i type /gos it always enable and don't disable so players can tele to me always!
(it compiles without any error)
please help me!
Thanks!
Код:
CMD:go(playerid, params[])
{
	new giveplayerid;
	if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE:/go(playerid) to teleport to that player");
	new Float:x;
	new Float:y;
	new Float:z;
	if(Goto == 1)
	{
		GetPlayerPos(giveplayerid, x,y,z);
		SetPlayerPos(playerid, x,y,z);
	}
	else if(Goto == 0)
	{
	    SendClientMessage(playerid, 0xFF0000FF, "That player disabled teleports to him!");
	}
	return 1;
}

CMD:gos(playerid, params[])
{
	if(Goto == 1)
	{
	    SendClientMessage(playerid, 0xFF0000FF, "You have disabled player from teleporting to you!");
	    Goto = 0;
	}
	if(Goto == 0)
	{
	    SendClientMessage(playerid, 0xFF0000FF, "You have enabled player from teleporting to you!");
	    Goto = 1;
	}
	return 1;
}
Whats the problem? when you do /go in game then whats happens?
Reply
#3

EDIT:
Код:
new Goto[MAX_PLAYERS] = 1;
CMD:go(playerid, params[]) {
	new TargetID, Float:X, Float:Y, Float:Z, Float:A;
	if(sscanf(params, "u", TargetID)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE:/go (playerid) to teleport to that player");
	if(Goto[TargetID] == 1) {
		GetPlayerPos(TargetID, X, Y, Z);
		GetPlayerFacingAngle(TarggetID, A);
		SetPlayerPos(playerid, X + 1, Y, Z);
		SetPlayerFacingAngle(playerid, A + 180);
	} else if(Goto[TargetID] == 0) {
	    SendClientMessage(playerid, 0xFF0000FF, "That player disabled teleports to him!");
	}
	return 1;
}

CMD:gos(playerid, params[]) {
	if(Goto[playerid] == 0) {
	    Goto[playerid] = 1;
	    SendClientMessage(playerid, 0xFF0000FF, "You have enabled player from teleporting to you!");
	} else {
	    Goto[playerid] = 0;
	    SendClientMessage(playerid, 0xFF0000FF, "You have disabled player from teleporting to you!");
	}
	return 1;
}
try now
Now the player will be teleported to the other player face to face (I think) if you don't want this remove Float:A, GetPlayerFacingAngle and SetPlayerFacingAngle
And "Goto" must to be for each player.
Reply
#4

the problem is with /gos when i write /gos it type
You have disabled gos
and
you have enabled gos
But it enable it and when i write /gos again it dont disable it
Reply
#5

Quote:
Originally Posted by bgedition
Посмотреть сообщение
EDIT:
Код:
new Goto[MAX_PLAYERS] = 1;
CMD:go(playerid, params[]) {
	new TargetID, Float:X, Float:Y, Float:Z, Float:A;
	if(sscanf(params, "u", TargetID)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE:/go (playerid) to teleport to that player");
	if(Goto[TargetID] == 1) {
		GetPlayerPos(TargetID, X, Y, Z);
		GetPlayerFacingAngle(TarggetID, A);
		SetPlayerPos(playerid, X + 1, Y, Z);
		SetPlayerFacingAngle(playerid, A + 180);
	} else if(Goto[TargetID] == 0) {
	    SendClientMessage(playerid, 0xFF0000FF, "That player disabled teleports to him!");
	}
	return 1;
}



CMD:gos(playerid, params[]) {
	if(Goto[playerid] == 0) {
	    Goto[playerid] = 1;
	    SendClientMessage(playerid, 0xFF0000FF, "You have enabled player from teleporting to you!");
	} else {
	    Goto[playerid] = 0;
	    SendClientMessage(playerid, 0xFF0000FF, "You have disabled player from teleporting to you!");
	}
	return 1;
}
try now
Now the player will be teleported to the other player face to face
And "Goto" must to be for each player.
You defined goto with MAX_PLAYERS, what thought come into mind dont you think it will disable command for playerid that uses it?
Reply
#6

Quote:
Originally Posted by GTLS
Посмотреть сообщение
You defined goto with MAX_PLAYERS, what thought come into mind dont you think it will disable command for playerid that uses it?
The variable must to be for each player as I can see in his/her cmd. Otherwise when one player use /gos he/she will disable teleporting for all players
Reply
#7

Quote:
Originally Posted by bgedition
Посмотреть сообщение
The variable must to be for each player as I can see in his/her cmd. Otherwise when one player use /gos he/she will disable teleporting for all players
I think thats what he needs, any admin can disable /go command for all other players... when any one of admin again will do /gos which will activate /go command again and all will be able to use it again?
Reply
#8

no my is any player can use /gos when he use it he disables/enables any other player from teleporting to him
Reply
#9

Quote:
Originally Posted by ironmen
Посмотреть сообщение
no my is any player can use /gos when he use it he disables/enables any other player from teleporting to him
okay my mistake but as bgedition gave you should work!
Reply
#10

Quote:
Originally Posted by bgedition
Посмотреть сообщение
The variable must to be for each player as I can see in his/her cmd. Otherwise when one player use /gos he/she will disable teleporting for all players
Thanks +1 rep
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)