Making a /spec & /specoff command
#1

Hey guys, I've been searching everywhere on ****** & samp forums. But all I found is spec commands which dont work. I don't want it as a filterscript. I would just like the commands, "/spec" and /specoff. I use ZCMD. I tried making some and they don't work, they turn out buggy and some come with errors.
Reply
#2

There is one in tutorial section.
If there is error give to us and we will try to solve it.
Reply
#3

Код:
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(39) : error 001: expected token: ";", but found "new"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(950) : warning 219: local variable "Name" shadows a variable at a preceding level
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(983) : warning 219: local variable "String" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
When I add the command, it's giving errors to another line which the Spectate command is not even related to.

Line 39:

Код:
new String[128], Float:SpecX[MAX_PLAYERS], Float:SpecY[MAX_PLAYERS], Float:SpecZ[MAX_PLAYERS], vWorld[MAX_PLAYERS], Inter[MAX_PLAYERS];
Line 946 - 951

Код:
stock PlayerName(playerid)
{
    new Name[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME + 1);
    return Name;
}
Line 981

Код:
new playerName[24], String[128];
// in a function not even related to the spec command

now the spec/spec off commands:

Код:
COMMAND:spec(playerid, params[])
{
    new id;// This will hold the ID of the player you are going to be spectating.
    if(!IsPlayerAdmin(playerid))return 0;// This checks if the player is logged into RCON, if not it will return 0; (Showing "SERVER: Unknown Command") You can replace it with your own admin check.
    if(sscanf(params,"u", id))return SendClientMessage(playerid, Grey, "Usage: /spec [id]");// Now this is where we use sscanf to check if the params were filled, if not we'll ask you to fill them
    if(id == playerid)return SendClientMessage(playerid,Grey,"You cannot spec yourself.");// Just making sure.
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, Grey, "Player not found!");// This is to ensure that you don't fill the param with an invalid player id.
    if(IsSpecing[playerid] == 1)return SendClientMessage(playerid,Grey,"You are already specing someone.");// This will make you not automatically spec someone else by mistake.
    GetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);// This is getting and saving the player's position in a variable so they'll respawn at the same place they typed '/spec'
    Inter[playerid] = GetPlayerInterior(playerid);// Getting and saving the interior.
    vWorld[playerid] = GetPlayerVirtualWorld(playerid);//Getting and saving the virtual world.
    TogglePlayerSpectating(playerid, true);// Now before we use any of the 3 functions listed above, we need to use this one. It turns the spectating mode on.
    if(IsPlayerInAnyVehicle(id))//Checking if the player is in a vehicle.
    {
        if(GetPlayerInterior(id) > 0)//If the player's interior is more than 0 (the default) then.....
        {
            SetPlayerInterior(playerid,GetPlayerInterior(id));//.....set the spectator's interior to that of the player being spectated.
        }
        if(GetPlayerVirtualWorld(id) > 0)//If the player's virtual world is more than 0 (the default) then.....
        {
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));//.....set the spectator's virtual world to that of the player being spectated.
        }
        PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));// Now remember we checked if the player is in a vehicle, well if they're in a vehicle then we'll spec the vehicle.
    }
    else// If they're not in a vehicle, then we'll spec the player.
    {
        if(GetPlayerInterior(id) > 0)
        {
            SetPlayerInterior(playerid,GetPlayerInterior(id));
        }
        if(GetPlayerVirtualWorld(id) > 0)
        {
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
        }
        PlayerSpectatePlayer(playerid,id);// Letting the spectator spec the person and not a vehicle.
    }
    GetPlayerName(id, Name, sizeof(Name));//Getting the name of the player being spectated.
    format(String, sizeof(String),"You have started to spectate %s.",Name);// Formatting a string to send to the spectator.
    SendClientMessage(playerid,0x0080C0FF,String);//Sending the formatted message to the spectator.
    IsSpecing[playerid] = 1;// Just saying that the spectator has begun to spectate someone.
    IsBeingSpeced[id] = 1;// Just saying that a player is being spectated (You'll see where this comes in)
    spectatorid[playerid] = id;// Saving the spectator's id into this variable.
    return 1;// Returning 1 - saying that the command has been sent.
}

COMMAND:specoff(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))return 0;// This checks if the player is logged into RCON, if not it will return 0; (Showing "SERVER: Unknown Command")
    if(IsSpecing[playerid] == 0)return SendClientMessage(playerid,Grey,"You are not spectating anyone.");
    TogglePlayerSpectating(playerid, 0);//Toggling spectate mode, off. Note: Once this is called, the player will be spawned, there we'll need to reset their positions, virtual world and interior to where they typed '/spec'
    return 1;
}
Please help
Reply
#4

Код:
stock StartPlayerSpec(playerid, otherid)
{
	TogglePlayerSpectating(playerid, 1);
	PlayerSpectatePlayer(playerid, otherid);
	SetPlayerInterior(playerid,GetPlayerInterior(otherid));
	SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(otherid));
	return 1;
}

stock StopPlayerSpec(playerid)
{
	TogglePlayerSpectating(playerid, 0);
	SetCameraBehindPlayer(playerid);
	return 1;
}

CMD:spec(playerid, params[])
{
	new pid;
	if(sscanf(params,"d",pid)) return SendClientMessage(playerid, "/spec [playerid]");
	if(GetPVarInt(playerid, "Spectating") == 1) return SendClientMessage(playerid, -1, "[SERVER]: You are already spectating. (/specoff)");
	if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, -1, "Invalid player is");
	SetPVarInt(playerid, "Spectating", 1);
	StartPlayerSpec(playerid, pid);
	return 1;
}

CMD:specoff(playerid, params[])
{
	if(GetIntVar(playerid, "Spectating") == 0) return SendClientMessage(playerid, COLOR_YELLOWG, "[SERVER]: You are not spectating.");
	DeletePVar(playerid, "Spectating");
	StopPlayerSpec(playerid);
	return 1;
}
Reply
#5

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
Код:
stock StartPlayerSpec(playerid, otherid)
{
	TogglePlayerSpectating(playerid, 1);
	PlayerSpectatePlayer(playerid, otherid);
	SetPlayerInterior(playerid,GetInterior(otherid));
	SetPlayerVirtualWorld(playerid, GetWorld(otherid));
	return 1;
}

stock StopPlayerSpec(playerid)
{
	TogglePlayerSpectating(playerid, 0);
	SetCameraBehindPlayer(playerid);
	return 1;
}

CMD:spec(playerid, params[])
{
	new pid;
	if(sscanf(params,"d",pid)) return SendClientMessage(playerid, "/spec [playerid]");
	if(GetIntVar(playerid, "Spectating") == 1) return SCM(playerid, COLOR_YELLOWG, "[SERVER]: You are already spectating. (/specoff)");
	if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, -1, "Invalid player is");
	SetIntVar(playerid, "Spectating", 1);
	StartPlayerSpec(playerid, pid);
	return 1;
}

CMD:specoff(playerid, params[])
{
	if(GetIntVar(playerid, "Spectating") == 0) return SendClientMessage(playerid, COLOR_YELLOWG, "[SERVER]: You are not spectating.");
	RemoveVar(playerid, "Spectating");
	StopPlayerSpec(playerid);
	return 1;
}
Код:
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(926) : error 017: undefined symbol "GetInterior"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(927) : error 017: undefined symbol "GetWorld"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2157) : error 035: argument type mismatch (argument 2)
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2158) : error 017: undefined symbol "GetIntVar"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2158) : error 017: undefined symbol "SCM"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2160) : error 017: undefined symbol "SetIntVar"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2167) : error 017: undefined symbol "GetIntVar"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2167) : error 017: undefined symbol "COLOR_YELLOWG"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2168) : error 017: undefined symbol "RemoveVar"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


9 Errors.
help plz!
Reply
#6

Try.

Код:
stock StartPlayerSpec(playerid, otherid)
{
	TogglePlayerSpectating(playerid, 1);
	PlayerSpectatePlayer(playerid, otherid);
	SetPlayerInterior(playerid,GetPlayerInterior(otherid));
	SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(otherid));
	return 1;
}

stock StopPlayerSpec(playerid)
{
	TogglePlayerSpectating(playerid, 0);
	SetCameraBehindPlayer(playerid);
	return 1;
}

CMD:spec(playerid, params[])
{
	new pid;
	if(sscanf(params,"d",pid)) return SendClientMessage(playerid, -1, "/spec [playerid]");
	if(GetPVarInt(playerid, "Spectating") == 1) return SendClientMessage(playerid, -1, "[SERVER]: You are already spectating. (/specoff)");
	if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, -1, "Invalid player id");
	SetPVarInt(playerid, "Spectating", 1);
	StartPlayerSpec(playerid, pid);
	return 1;
}

CMD:specoff(playerid, params[])
{
	if(GetPVarInt(playerid, "Spectating") == 0) return SendClientMessage(playerid, -1, "[SERVER]: You are not spectating.");
	DeletePVar(playerid, "Spectating");
	StopPlayerSpec(playerid);
	return 1;
}
TRY NOW
Reply
#7

Код:
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2157) : error 035: argument type mismatch (argument 2)
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2167) : error 017: undefined symbol "GetIntVar"
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\LOSSAN~1\GAMEMO~1\Testing.pwn(2167) : error 017: undefined symbol "COLOR_YELLOWG"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Help?
Reply
#8

Try.

Код:
stock StartPlayerSpec(playerid, otherid)
{
	TogglePlayerSpectating(playerid, 1);
	PlayerSpectatePlayer(playerid, otherid);
	SetPlayerInterior(playerid,GetPlayerInterior(otherid));
	SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(otherid));
	return 1;
}

stock StopPlayerSpec(playerid)
{
	TogglePlayerSpectating(playerid, 0);
	SetCameraBehindPlayer(playerid);
	return 1;
}

CMD:spec(playerid, params[])
{
	new pid;
	if(sscanf(params,"d",pid)) return SendClientMessage(playerid, -1, "/spec [playerid]");
	if(GetPVarInt(playerid, "Spectating") == 1) return SendClientMessage(playerid, -1, "[SERVER]: You are already spectating. (/specoff)");
	if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, -1, "Invalid player id");
	SetPVarInt(playerid, "Spectating", 1);
	StartPlayerSpec(playerid, pid);
	return 1;
}

CMD:specoff(playerid, params[])
{
	if(GetPVarInt(playerid, "Spectating") == 0) return SendClientMessage(playerid, -1, "[SERVER]: You are not spectating.");
	DeletePVar(playerid, "Spectating");
	StopPlayerSpec(playerid);
	return 1;
}
TRY NOW
Reply
#9

How can I spectate a player inside a vehicle and inside a interior?
Reply
#10

I'm currently at my phone.. But it'll work work with: SetPlayerVehicle and SetPlayerInterior (Not sure)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)