How do I make a /goto and /bring
#1

I was wondering how I could make a /bring to bring a player to me and a /goto to go to a player I have ZCMD.
Reply
#2

dont use that directly it will make many errors i only post that for basis
Код:
CMD:gethere(playerid, params[])
{
	new playerb, string[128];
	new Float:Pos[3];
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
	if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /goto [playerid]");
	if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
	if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
    if(Spec[playerb]) return SendClientMessage(playerid, COLOR_GREY, "Player is spectating someone.");
	GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
	if(IsPlayerInAnyVehicle(playerb) && GetPlayerState(playerb) == PLAYER_STATE_DRIVER && !GetPlayerInterior(playerid))
	{
    	SetVehiclePos(GetPlayerVehicleID(playerb), Pos[0]+2, Pos[1]+2, Pos[2]);
	}
	else
	{
	    SetPlayerPos(playerb, Pos[0]+1, Pos[1], Pos[2]);
	}
	SetPlayerInterior(playerb, GetPlayerInterior(playerid));
	SetPlayerVirtualWorld(playerb, GetPlayerVirtualWorld(playerid));
	format(string, sizeof(string), " You have teleported %s to you.", RPN(playerb));
	SendClientMessage(playerid, COLOR_WHITE, string);
	format(string, sizeof(string), " You have been teleported to admin %s.", RPN(playerid));
	SendClientMessage(playerb, COLOR_WHITE, string);
	return 1;
}
Код:
CMD:goto(playerid, params[])
{
	new playerb, string[128];
	new Float:Pos[3];
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
	if(PlayerInfo[playerid][pAdmin] < 2 && PlayerInfo[playerid][pHelper] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /goto [playerid]");
	if(!IsPlayerLoggedIn(playerb) && !IsPlayerNPC(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
	if(PlayerInfo[playerid][pHelper] && !PlayerInfo[playerid][pAdmin])
	{
	    if(!HelpTime[playerb]) return SendClientMessage(playerid, COLOR_GREY, "This player hasn't requested any help.");
	   	if(hPos[playerid][0] == 0 && hPos[playerid][1] == 0 && hPos[playerid][2] == 0 && hPOS[playerid][0] == 0 && hPOS[playerid][0] == 0)
	   	{
		    GetPlayerPos(playerid, hPos[playerid][0], hPos[playerid][1], hPos[playerid][2]);
		    hPOS[playerid][0] = GetPlayerInterior(playerid);
		    hPOS[playerid][1] = GetPlayerVirtualWorld(playerid);
			GetPlayerPos(playerb, Pos[0], Pos[1], Pos[2]);
			SetPlayerPos(playerid, Pos[0]+1, Pos[1], Pos[2]);
			SetPlayerInterior(playerid, GetPlayerInterior(playerb));
			SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));
			format(string, sizeof(string), " You have teleported to %s.", RPN(playerb));
			SendClientMessage(playerid, COLOR_WHITE, string);
			format(string, sizeof(string), " %s %s has teleported to you.", RPHLN(playerid), RPN(playerid));
			SendClientMessage(playerb, COLOR_WHITE, string);
			format(string, sizeof(string), "HelpWarn: %s has teleported to %s.", RPN(playerid), RPN(playerb));
			SendHelperMessage(COLOR_DARKRED, 1, string);
		}
		else SendClientMessage(playerid, COLOR_GREY, "You must /goback before teleporting to another player.");
	}
	else
	{
		if(Spec[playerb]) return SendClientMessage(playerid, COLOR_GREY, "Player is spectating someone.");
		GetPlayerPos(playerb, Pos[0], Pos[1], Pos[2]);
		if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
		    SetVehiclePos(GetPlayerVehicleID(playerid), Pos[0]+2, Pos[1]+2, Pos[2]);
		}
		else
		{
		    SetPlayerPos(playerid, Pos[0]+1, Pos[1], Pos[2]);
		}
		SetPlayerInterior(playerid, GetPlayerInterior(playerb));
		SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));
		format(string, sizeof(string), " You have teleported to %s.", RPN(playerb));
		SendClientMessage(playerid, COLOR_WHITE, string);
		format(string, sizeof(string), " Administrator %s has teleported to you.", RPN(playerid));
		SendClientMessage(playerb, COLOR_WHITE, string);
	}
	return 1;
}
Reply
#3

Well you need sscanf, look it up if you don't already have it.
pawn Код:
CMD:goto(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5) //== You would have something similar or you might not have it if you want anyone in the server to use the command
    {
        new Float:x, Float:y, Float:z, targetid;
        if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, C_WHITE, "Usage: /goto [Player ID/Name]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, C_RED, "Error: This player is not connected.");

        GetPlayerPos(targetid, x, y, z); //== Get's the player position of the player you wish to go to
        SetPlayerPos(playerid, x, y, z); //== Set's your position to his
    }
    else SendClientMessage(playerid, C_RED, "Invalid command, type /cmds to see a list of all our server commands."); //== If the player trying to use the command is not admin they will get this
    return 1;
}

CMD:get(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        new Float:x, Float:y, Float:z, targetid;
        if(sscanf(params,"ui", targetid)) return SendClientMessage(playerid, C_WHITE, "Usage: /get [Player ID/Name]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, C_RED, "Error: This player is not connected.");

        GetPlayerPos(playerid, x, y, z); //== Same as above only here the code will get your position
        SetPlayerPos(targetid, x, y+1, z); //== And bring the target to you
    }
    else SendClientMessage(playerid, C_RED, "Invalid command, type /cmds to see a list of all our server commands.");
    return 1;
}
This is pretty basic and you can copy paste it. You would need to define the color's or change these.
Reply
#4

Thanks Rillo how would I do a /setadmin with the pAdmin enum?
Reply
#5

Also with the /get command when it is typed in on the console it says sscanf warning:Format specifier does not match parameter count
Reply
#6

Quote:
Originally Posted by lramos15
Посмотреть сообщение
Also with the /get command when it is typed in on the console it says sscanf warning:Format specifier does not match parameter count
Sorry about that, don't know how it got there or why but that i should not be there.

pawn Код:
if(sscanf(params,"ui", targetid)) return SendClientMessage(playerid, C_WHITE, "Usage: /get [Player ID/Name]");
Remove that "i" in the params and you won't get any warnings.

As for the admin command.

pawn Код:
CMD:setadmin(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] == 6) //== Or whatever you have for the server owner, you could even do IsPlayerAdmin so it's only an rcon command
    {
        new targetid,level;
        if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, C_RED, "Usage: /setadmin [Player ID/Name] [level]");
       
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, C_RED, "Error: This player is not connected.");

        PlayerInfo[targetid][pAdmin] = level; //== This will set the target's admin level to the one you enter
    }
    else return SendClientMessage(playerid, C_RED, "Invalid command, type /cmds to see a list of all our server commands.");
    return 1;
}
Reply
#7

Whats pAuth?
Reply
#8

Quote:
Originally Posted by lramos15
Посмотреть сообщение
Whats pAuth?
It was suppose to be pAdmin. You might have something else, like pLevel...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)