Quote:
Originally Posted by Kindred
Try something like this:
pawn Код:
new GotoDisabled[MAX_PLAYERS];
public OnPlayerConnect(playerid) { GotoDisabled[playerid] = 0; //Rest of code for OnPlayerConnect return 1; }
CMD:goff(playerid, params[]) { if(IsPlayerConnected(playerid)) { if(GotoDisabled[playerid] == 1) return GotoDisabled[playerid] = 0; else return GotoDisabled[playerid] = 0; } return 1; }
CMD:go(playerid, params[]) { new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line if(sscanf(params, "u", ID)) SendClientMessage(playerid, 0xFF0000FF, "USAGE: /goto [id]");//checks if you have written something after /goto if no it sends error else if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself"); <--------------This is the error line. if(GotoDisabled[ID] == 1) { new string[50], name[MAX_PLAYER_NAME]; format(string, sizeof(string), "%s's goto is disabled!", GetPlayerName(playerid, name, sizeof(name))); GameTextForPlayer(playerid,string,2000,3); return 1; } else//ELSE what will happen if no errors { new Float:x, Float:y, Float:z;//creates new floats GetPlayerPos(ID, x, y, z);//gets the player id(which we have entered after /goto position and like saves them into x,y,z defined above as floats SetPlayerPos(playerid, x+1, y+1, z);//sets the player position the id of that player +1 in x +1 in y and z remains same as it defines height } return 1; }
Should work with no errors.
Hope I helped.
|
Dude, no error. But if i use /go it teleports me to my position. Also if i type /goff a gametextforplayer will also show to my screen like this GameTextForPlayer(playerid,"~b~You have ~r~disabled ~b~go",2000,3);