Tag mismatch, BUT WHY!?
#1

On the following line:

pawn Код:
COMMAND:spec(playerid,params[])
{
    #if EnableSpectate == true

            if(gPlayerSpectating[playerid] == 0)
            {
                new Target;
                if(sscanf(params, "u", Target)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /spec [playerid]");

                    if(gPlayerSpectating[Target] == 0)
                    {
                        if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: You can't spec yourself!");
                        if(!IsPlayerConnected(Target))
                            return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
                           
                        TogglePlayerSpectating(playerid, 1);
                        PlayerSpectatePlayer(playerid, Target);
                        SetPlayerInterior(playerid,GetPlayerInterior(Target));
                        gSpectateID[playerid] = Target;
                        gPlayerSpectating[playerid] = 1;
                        gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
                        new tname[MAX_PLAYER_NAME];
                        GetPlayerName(Target,tname,sizeof(tname));
                        new MyString[128];
                        format(MyString,sizeof MyString, "You are now spectating %s! Type /specoff to stop!", tname);
                        SendClientMessage(playerid, COLOR_GREEN, MyString);
                        new Float:hp, Float:ar;
                        GetPlayerHealth(Target, hp);
                        GetPlayerArmour(Target, ar);
                        //format(specstring, sizeof(specstring), "~g~SPECTATING PLAYER: ~w~%s(%d)~n~~w~Type ~y~/specoff ~w~to stop!\nHealth: %d\nArmour: %d",tname, Target, GetPlayerHealth(Target, health), GetPlayerArmour(Target,armour));
                        format(MyString, 256, "~w~- %s(%d) -~n~~n~~y~Health: ~w~%0.1f ~l~- ~y~Armour: ~w~%0.1f ~l~- ~y~Money: ~w~$%d~n~~n~~r~< Sprint - Jump >", MyString,tname,hp,ar,GetPlayerMoney(tname));
                        TextDrawSetString(SpectationText, MyString);
                        TextDrawShowForPlayer(playerid,SpectationText);


                    }
                    else return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is in spectate mode!");
            }
            else return SendClientMessage(playerid,COLOR_RED,"ERROR: You are already in spectate mode!");

    #endif
    return 1;
}
pawn Код:
format(MyString, 256, "~w~- %s(%d) -~n~~n~~y~Health: ~w~%0.1f ~l~- ~y~Armour: ~w~%0.1f ~l~- ~y~Money: ~w~$%d~n~~n~~r~< Sprint - Jump >", MyString,tname,hp,ar,GetPlayerMoney(tname));
Reply
#2

....Learn what parameters of functions are before you use them...


GetPlayerMoney(Target)
Reply
#3

Ah, okay, thanks! Yeah sorry bro, I'm a little tired, it's 5:00 AM here...
Reply
#4

Okay, I've tried to spectate someone now on my server, but the textdraw won't appear! WHY?

pawn Код:
CMD:spec(playerid,params[])
{


            if(gPlayerSpectating[playerid] == 0)
            {
                new Target;
                if(sscanf(params, "u", Target)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /spec [playerid]");

                    if(gPlayerSpectating[Target] == 0)
                    {
                        if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: You can't spec yourself!");
                        if(!IsPlayerConnected(Target))
                            return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
                           
                        TogglePlayerSpectating(playerid, 1);
                        PlayerSpectatePlayer(playerid, Target);
                        SetPlayerInterior(playerid,GetPlayerInterior(Target));
                        gSpectateID[playerid] = Target;
                        gPlayerSpectating[playerid] = 1;
                        gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
                        new tname[MAX_PLAYER_NAME];
                        GetPlayerName(Target,tname,sizeof(tname));
                        new MyString[128];
                        format(MyString,sizeof MyString, "You are now spectating %s! Type /specoff to stop!", tname);
                        SendClientMessage(playerid, COLOR_GREEN, MyString);
                        new Float:hp, Float:ar;
                        GetPlayerHealth(Target, hp);
                        GetPlayerArmour(Target, ar);
                        //format(specstring, sizeof(specstring), "~g~SPECTATING PLAYER: ~w~%s(%d)~n~~w~Type ~y~/specoff ~w~to stop!\nHealth: %d\nArmour: %d",tname, Target, GetPlayerHealth(Target, health), GetPlayerArmour(Target,armour));
                        format(MyString, 256, "~w~- %s(%d) -~n~~n~~y~Health: ~w~%0.1f ~l~- ~y~Armour: ~w~%0.1f ~l~- ~y~Money: ~w~$%d~n~~n~~r~< Sprint - Jump >", MyString,tname,hp,ar,GetPlayerMoney(Target));
                        TextDrawSetString(SpectationText, MyString);
                        TextDrawShowForPlayer(playerid,SpectationText);


                    }
                    else return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is in spectate mode!");
            }
            else return SendClientMessage(playerid,COLOR_RED,"ERROR: You are already in spectate mode!");

        return 1;
}

CMD:specoff(playerid,params[])
{
 
            if(gPlayerSpectating[playerid] == 1)
            {
                TogglePlayerSpectating(playerid, 0);
                gSpectateID[playerid] = INVALID_PLAYER_ID;
                gPlayerSpectating[playerid] = 0;
                gSpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
                SendClientMessage(playerid, COLOR_GREEN, "You have stopped spectating!");
                TextDrawHideForPlayer(playerid,SpectationText);
            }
            else SendClientMessage(playerid,COLOR_RED,"ERROR: You are not in spectate mode!");
   

    return 1;
}
Reply
#5

You are formatting "MyString" with MyString? Doesn't make sense.
this is what you are doing.
pawn Код:
format(MyString, 256, "%s",MyString);
Reply
#6

Oh, I just saw that now, lol! So it gotta look like that?

pawn Код:
format(MyString, sizeof(MyString) " %s");
Reply
#7

well if your useing format(MyString, sizeof(MyString) " %s",MyString);

it would just update itself with itself
it would be like writing somevar = somevar;
Reply
#8

So how shall I use it? I thought the way I've posted was right!?
Reply
#9

well it can be used like that just what your doing i not correct,

look at this line
pawn Код:
format(MyString, 256, "~w~- %s(%d) -~n~~n~~y~Health: ~w~%0.1f ~l~- ~y~Armour: ~w~%0.1f ~l~- ~y~Money: ~w~$%d~n~~n~~r~< Sprint - Jump >", MyString,tname,hp,ar,GetPlayerMoney(Target));
format expects :
string
int
float
float
int


and your passing:

string (old mystring var) read below
string (tname)
float (hp)
float (armor)
int (GetPlayerMoney(Target))



as far as mystring goes it contains "You are now spectating %s! Type /specoff to stop!"
already, and enless you want that included in your TD string....
this is why it was questioned.

but I have used it like this also in my code looks something like
pawn Код:
new i,aSize,strDialog[1024];
        aSize = sizeof(aWeaponNames);
        for (i=0;i<aSize;i++){
            if (i==0) format(strDialog, sizeof (strDialog), "%s", aWeaponNames[i][eWeaponN_Name]);
            else format(strDialog, sizeof (strDialog), "%s\n%s",strDialog, aWeaponNames[i][eWeaponN_Name]);
        }


hope this clears it up
Reply
#10

Yes, I certainly know now what I did wrong. But I still don't know how the new code should look like.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)