i made this command help.
#1

Hello, i made this, i know its not the best but i want to do a "cameraman" function to spectate another player and see him in first person ( i want to do a "news" in my rp server ).

So i made this:

pawn Код:
CMD:camaraman(playerid, params[])
{
new userID;
if(sscanf(params, "u", userID)) return SendClientMessage(playerid, -1, "/spec [playerid]");
if(!IsPlayerConnected(userID)) return SendClientMessage(playerid, -1, "* No conectado.");
SetPlayerInterior(playerid, GetPlayerInterior(userID));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(userID));
AttachObjectToPlayer(FPS2[userID], playerid, 0.0, 0.15, 0.65, 0.0, 0.0, 0.0);
AttachCameraToObject(playerid, FPS2[userID]);
return 1;
}
The problem its, i tested with a friend, and sometimes the /spec doesn't work, i mean , sometimes when you write /spec (id of your friend) most of time you see yourself in first person.

And when its working, sometimes its buggy and you can move the camera like if you were your friend ( i want that you can't move the camera, if the player that you're spectating moves, the camera moves).

If someone can help me , i would be grateful. Thanks.
Reply
#2

Quote:

The problem its, i tested with a friend, and sometimes the /spec doesn't work, i mean , sometimes when you write /spec (id of your friend) most of time you see yourself in first person.

AttachObjectToPlayer(FPS2[userID], playerid, 0.0, 0.15, 0.65, 0.0, 0.0, 0.0);

You are attaching the object on yourself, it should be userID instead.
Reply
#3

Thanks! now its working like its supposed. Now, i want that you can't move the camera, and when i write something in the chat, the player that i'm specting to, he can read what i'm saying
Reply
#4

pawn Код:
new bool:cameraman[MAX_PLAYERS],
        FPS2[MAX_PLAYERS];

public OnPlayerText(playerid, text[])
{
    if(cameraman[playerid] == true)
        return SendClientMessage(playerid, -1, "You can't use chat while using /cameraman");

    return 0;
}

CMD:camaraman(playerid, params[])
{
    new userID;
    if(sscanf(params, "u", userID)) return SendClientMessage(playerid, -1, "/spec [playerid]");
    if(!IsPlayerConnected(userID)) return SendClientMessage(playerid, -1, "* No conectado.");

    cameraman[playerid] = true;

    SetPlayerInterior(playerid, GetPlayerInterior(userID));
    SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(userID));
    AttachObjectToPlayer(FPS2[userID], playerid, 0.0, 0.15, 0.65, 0.0, 0.0, 0.0);
    AttachCameraToObject(playerid, FPS2[userID]);

    return 1;
}
You'll need to make a command to set the cameraman variable back to false so the player can talk again
Reply
#5

Hi wolfe, thanks for your help, but i have errors.

with this line
pawn Код:
{
    if(cameraman[playerid] == true)
        return SendClientMessage(playerid, -1, "You can't use chat while using /cameraman");

    return 0;
}
(49333) : error 055: start of function body without function header
(49334) : error 010: invalid function or declaration
(49335) : error 010: invalid function or declaration
(49337) : error 010: invalid function or declaration
Reply
#6

Quote:

Hi wolfe, thanks for your help, but i have errors.

with this line
Code:
{
if(cameraman[playerid] == true)
return SendClientMessage(playerid, -1, "You can't use chat while using /cameraman");

return 0;
}

(49333) : error 055: start of function body without function header
(49334) : error 010: invalid function or declaration
(49335) : error 010: invalid function or declaration
(49337) : error 010: invalid function or declaration

Make sure you copied that in the right position within the public calback : " public OnPlayerText(playerid, text[]) ", and that you have inserted these in the head of your script or outside the publics ..

Код:
new bool:cameraman[MAX_PLAYERS],
		FPS2[MAX_PLAYERS];
Show me your public OnPlayerText.
Reply
#7

Yeah all that without the public onplayertext, and i defined all before.

For example if i put it here:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(DetectarSpam(text)) { SendClientMessage(playerid,0xFFFFFFFF,"Hiciste SPAM."); return 0; }
    // Anti-MG
    if(strfind(text, "=)", true) != -1 || strfind(text, "xD", true) != -1 || strfind(text, "=V", true) != -1 || strfind(text, "Gay", true) != -1 || strfind(text, "Noob", true) != -1 || strfind(text, "RP", true) != -1 || strfind(text, ":D", true) != -1 || strfind(text, ":c", true) != -1)
    {
    SendClientMessage(playerid,0xDC092FFF,"No hagas MG, podrбs ser sancionado.");
    return 0;
    }
    new sendername[MAX_PLAYER_NAME],string[256],tmp[32];
    new giveplayer[MAX_PLAYER_NAME];
    if(Muted[playerid] == 1)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "* ЎHas sido silenciado!");
        return 0;
    }
    if(!gPlayerLogged{playerid})
    {
        SendClientMessageEx(playerid, COLOR_GENERAL, "No puedes usar el chat en el Login - Kikeado automбticamente.");
        Kick(playerid);
        return 0;
    }
    if(TutStep[playerid] >= 1)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "* Estбs en el tutorial no puedes hablar.");
        return 0;
    }
        // Aquн:
    new Asterisco = strfind(text, "*");
    if(Asterisco != -1 && text[Asterisco+1] != '*')
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "* %s ", sendername);
        strmid(string, text, 0, strlen(text));
        strdel(string, Asterisco, Asterisco+1);
        strins(string, "{FF80FF}- ", Asterisco);
        format(tmp, sizeof(string), "%s dice: ", sendername); // Para cambiar lo que aparece al principio (* Nombre_Apellido ), edita esta lнnea.
        strins(string, tmp, 0);
        ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        return 0;
    }
    {
    if(cameraman[playerid] == true)
        return SendClientMessage(playerid, -1, "You can't use chat while using /cameraman");

    return 0;
    }
    if(TalkingLive[playerid] != INVALID_PLAYER_ID)
    {
        if(Team_LSTV(playerid))
        {
            format(string, sizeof(string), "[News Live] Reportero %s: %s", GetPlayerNameEx(playerid), text);
            OOCNews(COLOR_NEWS2, string);
        }
        else
        {
            format(string, sizeof(string), "[News Live] Invitado %s: %s", GetPlayerNameEx(playerid), text);
            OOCNews(COLOR_NEWS2, string);
        }
        return 0;
    }
Error "Unreacheable code" on the next line.
In the beggining those four errrors.

And now if i put it between this two stocks:

pawn Код:
ClearChatbox(playerid)
{
    for(new i = 0; i < 10; i++)
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "");
    }
    return 1;
}
    {
    if(cameraman[playerid] == true)
        return SendClientMessage(playerid, -1, "You can't use chat while using /cameraman");

    return 0;
    }
stock IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
The four errors again . thanks.
Reply
#8

Do this and put it in the beginning of the public OnPlayerText :

PHP код:
public OnPlayerText(playeridtext[])
{
     if(
cameraman[playerid] == true)
     {
          
SendClientMessage(playerid, -1"You can't use chat while using /cameraman");
          return 
0;
     } 
Reply
#9

Thanks for helping , but look, tons of errors if i put it there. Now i tried this and its working i THINK.

[PAWN]public OnPlayerText(playerid, text[])
{
if(DetectarSpam(text)) { SendClientMessage(playerid,0xFFFFFFFF,"Hiciste SPAM."); return 0; }
// Anti-MG
if(strfind(text, "=)", true) != -1 || strfind(text, "xD", true) != -1 || strfind(text, "=V", true) != -1 || strfind(text, "Gay", true) != -1 || strfind(text, "Noob", true) != -1 || strfind(text, "RP", true) != -1 || strfind(text, "", true) != -1 || strfind(text, ":c", true) != -1)
{
SendClientMessage(playerid,0xDC092FFF,"No hagas MG, podrбs ser sancionado.");
return 0;
}
new sendername[MAX_PLAYER_NAME],string[256],tmp[32];
new giveplayer[MAX_PLAYER_NAME];
if(Muted[playerid] == 1)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "* ЎHas sido silenciado!");
return 0;
}
if(!gPlayerLogged{playerid})
{
SendClientMessageEx(playerid, COLOR_GENERAL, "No puedes usar el chat en el Login - Kikeado automбticamente.");
Kick(playerid);
return 0;
}
if(TutStep[playerid] >= 1)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "* Estбs en el tutorial no puedes hablar.");
return 0;
}
// Aquн:
new Asterisco = strfind(text, "*");
if(Asterisco != -1 && text[Asterisco+1] != '*')
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s ", sendername);
strmid(string, text, 0, strlen(text));
strdel(string, Asterisco, Asterisco+1);
strins(string, "{FF80FF}- ", Asterisco);
format(tmp, sizeof(string), "%s dice: ", sendername); // Para cambiar lo que aparece al principio (* Nombre_Apellido ), edita esta lнnea.
strins(string, tmp, 0);
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
return 0;
}
{
if(cameraman[playerid] == true)
return SendClientMessage(playerid, -1, "You can't use chat while using /cameraman");

//return 0; I PUT // In this line and now it compiled all right.
}
if(TalkingLive[playerid] != INVALID_PLAYER_ID)
{
if(Team_LSTV(playerid))
{
format(string, sizeof(string), "[News Live] Reportero %s: %s", GetPlayerNameEx(playerid), text);
OOCNews(COLOR_NEWS2, string);
}
else
{
format(string, sizeof(string), "[News Live] Invitado %s: %s", GetPlayerNameEx(playerid), text);
OOCNews(COLOR_NEWS2, string);
}
return 0;
}
Reply
#10

Yes, because you can't start a function {} without a header so you have to make an if statement at the beginning then make your code .. and uh.. My code didn't work because of the " if(Muted[playerid] == 1) " so you have to put it after that and use just one return, don't return both of the message and 0 .
I hope you could have fixed your problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)