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; }
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; } |
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; }
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; } 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?
|
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
|
no my is any player can use /gos when he use it he disables/enables any other player from teleporting to him
|
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
|