/setvw and /setint problems and /goto and /gethere issues
#1

I just wrote up these commands for /setvw and /setint, but they're not working. It doesn't make sense to me, as I'm pretty confident I did it right, so here's those commands:

Код:
CMD:setint(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 1)
	{
	    new IntID, targetid, sendername, string[128];
 		if(sscanf(params, "ui", targetid, IntID)) return SendClientMessage(playerid, -1, "Usage: /setint [player/partofname] [interior ID]");
		SetPlayerInterior(playerid, IntID);
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "Your interior has been set to %i by Admin %s!",IntID,sendername);
        SendClientMessage(targetid, -1, string);
        GetPlayerName(targetid, sendername, sizeof(sendername));
        format(string, sizeof(string), "You have set %s's interior to %i!",sendername,IntID);
        SendClientMessage(playerid, -1, string);
		return  1 ;
	}
	return 1;
}

CMD:setvw(playerid,params[])
{
    new vw, sendername, string, id;
	if(PlayerInfo[playerid][pAdmin] < 1)
	{
		SendClientMessage(playerid, -1, "You are not a high enough leveled administrator to use this command!");
	}
    else
    {
   		if(sscanf(params, "ui", id, vw)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /setvw [playerid] [virtualworld]");
    	if(vw > 2000) return SendClientMessage(playerid, COLOR_WHITE, "Must not exceed 2000");
    	else if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player not found.");
        SetPlayerVirtualWorld(id,vw);
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "Your virtual world has been set to %i by Admin %s!",IntID,sendername);
        SendClientMessage(id, -1, string);
        GetPlayerName(id, sendername, sizeof(sendername));
        format(string, sizeof(string), "You have set %s's virtual world to %i!",sendername,IntID);
        SendClientMessage(playerid, -1, string);
        return 1;
    }
    return 1;
}
And the errors:

PHP код:
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2637) : error 035argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2637) : error 035argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2640) : error 035argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2640) : error 035argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2661) : error 035argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2661) : error 035argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2662) : error 035argument type mismatch (argument 1)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2662) : error 035argument type mismatch (argument 1)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2663) : error 035argument type mismatch (argument 3)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2664) : error 035argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2664) : error 035argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2665) : error 035argument type mismatch (argument 1)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2665) : error 035argument type mismatch (argument 1)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2666) : error 035argument type mismatch (argument 3)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2650) : warning 203symbol is never used"string"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
14 Errors

And then the odd part about my /goto and /gethere commands are that they work 100 percent, and in fact used to work entirely, but for some reason now whenever they're used it just teleports you to some random point(often times that bugged farm in blueberry). Is there anything visibly wrong with these commands, or could it be something else? I'd appreciate any help you can give me. Here's those cmds:

Код:
CMD:gethere(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 2)
	{
		new targetid, naot[128], sendername[MAX_PLAYER_NAME];
		if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/gethere [playerid/partofname]");
		new Float:Tpos[3];
		if(PlayerInfo[targetid][pAdmin] >= PlayerInfo[playerid][pAdmin])
		{
		    SendClientMessage(playerid, -1, "You cannot teleport an admin of equal or greater rank!");
		    return 1;
		}
		else
		{
   			if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not online!");
			GetPlayerPos(playerid, Tpos[0], Tpos[1], Tpos[2]);
			SetPlayerPos(targetid, Tpos[0+2], Tpos[1], Tpos[2]);
			GetPlayerName(playerid, sendername, sizeof(sendername));
			format(naot, sizeof(naot), "You have been teleported by admin *%s!", sendername);
			SendClientMessage(targetid, -1, naot);
			GetPlayerName(targetid, sendername, sizeof(sendername));
			format(naot, sizeof(naot), "You have teleported *%s to you.", sendername);
			SendClientMessage(playerid, -1, naot);
		}
		return 1;
	}
	return 1;
}

CMD:goto(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 2)
	{
 		new targetid, naot[128], sendername[MAX_PLAYER_NAME];
 		if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/goto [playerid/partofname]");
	    new Float:Gpos[3];
	    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not online!");
		GetPlayerPos(targetid, Gpos[0], Gpos[1], Gpos[2]);
		SetPlayerPos(playerid, Gpos[0+1], Gpos[1+1], Gpos[2]);
  		GetPlayerName(playerid, sendername, sizeof(sendername));
    	format(naot, sizeof(naot), "Admin *%s has teleported to you!", sendername);
     	SendClientMessage(targetid, -1, naot);
      	GetPlayerName(targetid, sendername, sizeof(sendername));
       	format(naot, sizeof(naot), "You have teleported to *%s.", sendername);
       	SendClientMessage(playerid, -1, naot);
	}
	return 1;
}
Reply
#2

You declared 'string' and 'sendername' wrong in your 'setvw' command:
pawn Код:
new vw, sendername, string, id;
Reply
#3

First, in "setint" and "setwv" command, the variable "sendername" must be a string.
pawn Код:
new sendername[MAX_PLAYER_NAME+1];
In "setwv" command, the variable "string" must be also a string.
Reply
#4

Alright thanks for the help, I got it fixed up. Does anyone have any idea about the /goto and /gethere cmds?
Reply
#5

pawn Код:
SetPlayerPos(targetid, Tpos[0+2], Tpos[1], Tpos[2]);
^ The value that goes inside the square brackets is the index of the variable in the array.

Correct way of doing it:
pawn Код:
SetPlayerPos(targetid, Tpos[0]+2, Tpos[1], Tpos[2]);
Your problem is the same for both commands.

Also, not part of your current problem, but worth noting: you are using 'targetid' inside of an array before checking if it's a valid player, which would be an invalid index if 'targetid' is not connected.
Reply
#6

Quote:
Originally Posted by Catalyst-
Посмотреть сообщение
pawn Код:
SetPlayerPos(targetid, Tpos[0+2], Tpos[1], Tpos[2]);
^ The value that goes inside the square brackets is the index of the variable in the array.

Correct way of doing it:
pawn Код:
SetPlayerPos(targetid, Tpos[0]+2, Tpos[1], Tpos[2]);
Your problem is the same for both commands.
Oh, thanks very much. I never really knew that until now. I thought both ways did the same thing, so thanks once again!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)