[Ajuda] Erro bбsico em String
#1

Galera, ajudem pfvr, nao sei oq esta dando de errado nessas strings


Код:
new Float:Angle, string[26];
GetPlayerFacingAngle(playerid, Angle);
if(Angle[playerid] == 0) // linha 56
Erros
Код:
C:\Users\User4\Desktop\conce.pwn(54) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User4\Desktop\conce.pwn(56) : error 028: invalid subscript (not an array or too many subscripts): "Angle"
C:\Users\User4\Desktop\conce.pwn(56) : warning 215: expression has no effect
C:\Users\User4\Desktop\conce.pwn(56) : error 001: expected token: ";", but found "]"
C:\Users\User4\Desktop\conce.pwn(56) : error 029: invalid expression, assumed zero
C:\Users\User4\Desktop\conce.pwn(56) : fatal error 107: too many error messages on one line
Ajudem ae pfvr!
Reply
#2

pawn Код:
new Float:Angle;
GetPlayerFacingAngle(playerid, Angle);
if(Angle == 0) // linha 56
Sobre a variбvel, ela jб foi declarada anteriormente!
Reply
#3

Aproveitando o tуpico, como corrijo isso ?

undefined symbol "SetMyFacingAngle"
Reply
#4

Quote:
Originally Posted by davi54723
Посмотреть сообщение
Aproveitando o tуpico, como corrijo isso ?

undefined symbol "SetMyFacingAngle"
pawn Код:
new Float: Angulo;
Angulo = 180.0;
SetPlayerFacingAngle( playerid, Angulo );
OBS: Valores e variбveis usadas sгo apenas uma demonstraзгo!
Reply
#5

Obrigado!
Reply
#6

Opa, blz Castiel, consegui arrumar com o seu post, mas, eu digito o comando e n acontece nada..
Alguem sabe pq ?
(Sei que strtok й ultrapassado, mas qero pelo menos aprender como mexer nele)


pawn Код:
#include <a_samp>

new Float:px, Float:py, Float:pz;

public OnFilterScriptInit()
{
return 1;
}

public OnFilterScriptExit()
{
return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{

    new string[256];

    new cmd[128], idx;
    new tmp[128];
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/cumprimentar", true) == 0)
        {
         

            tmp = strtok(cmdtext, idx);
       
            if(strlen(tmp) == 0)
            return SendClientMessage(playerid, -1, "USO: /cumprimentar [ID/ParteDoNome]");
       
            new otherid;
            otherid = ReturnUser(tmp);
                               
            if(!IsPlayerConnected(otherid))
            return SendClientMessage(playerid, -1, "Esse Player nao estб conectado");
           
           
            GetPlayerPos(otherid, px, py, pz);
           
            if(!IsPlayerInRangeOfPoint(playerid, 2.0, px, py, pz))
            return SendClientMessage(playerid, -1, "Aproxime-se do jogador");
           
           
            new pname[MAX_PLAYER_NAME];
            new oname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pname, sizeof(pname));
            GetPlayerName(otherid,  oname, sizeof(oname));
           
            new Float:Angle;
            GetPlayerFacingAngle(playerid, Angle);
            if(Angle == 0)
            {
            SetPlayerFacingAngle(otherid, 180);
            ApplyAnimation(playerid, "GANGS", "hndshkaa", 4.0, 1, 0, 0, 0, 0);
            ApplyAnimation(otherid, "GANGS", "hndshkaa", 4.0, 1, 0, 0, 0, 0);
            format(string, sizeof(string), "Vocк comprimentou %s", oname);
            SendClientMessage(playerid, -1, string);
            format(string, sizeof(string), "Vocк comprimentou %s", pname);
            SendClientMessage(otherid, -1, string);
            }
            if(Angle == 180)
            {
            SetPlayerFacingAngle(otherid, 0);
            ApplyAnimation(playerid, "GANGS", "hndshkaa", 4.0, 1, 0, 0, 0, 0);
            ApplyAnimation(otherid, "GANGS", "hndshkaa", 4.0, 1, 0, 0, 0, 0);
            format(string, sizeof(string), "Vocк comprimentou %s", oname);
            SendClientMessage(playerid, -1, string);
            format(string, sizeof(string), "Vocк comprimentou %s", pname);
            SendClientMessage(otherid, -1, string);
            }
            if(Angle == 90)
            {
            SetPlayerFacingAngle(otherid, 270);
            ApplyAnimation(playerid, "GANGS", "hndshkaa", 4.0, 1, 0, 0, 0, 0);
            ApplyAnimation(otherid, "GANGS", "hndshkaa", 4.0, 1, 0, 0, 0, 0);
            format(string, sizeof(string), "Vocк comprimentou %s", oname);
            SendClientMessage(playerid, -1, string);
            format(string, sizeof(string), "Vocк comprimentou %s", pname);
            SendClientMessage(otherid, -1, string);
            }
            if(Angle == 270)
            {
            SetPlayerFacingAngle(otherid, 90);
            ApplyAnimation(playerid, "GANGS", "hndshkaa", 4.0, 1, 0, 0, 0, 0);
            ApplyAnimation(otherid, "GANGS", "hndshkaa", 4.0, 1, 0, 0, 0, 0);
            format(string, sizeof(string), "Vocк comprimentou %s", oname);
            SendClientMessage(playerid, -1, string);
            format(string, sizeof(string), "Vocк comprimentou %s", pname);
            SendClientMessage(otherid, -1, string);
            }
            return 1;
        }
   
    return 0;
}

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}



ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21)
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos]))
    {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
            {
               
                {
                    SendClientMessage(playerid, 0xFF0000AA, "User not connected");
                }
                userid = INVALID_PLAYER_ID;
            }
            else
            {
                return userid;
            }
        }

    }
    new len = strlen(text[pos]);
    new count = 0;
    new name[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof (name));
            if (strcmp(name, text[pos], true, len) == 0)
            {
                if (len == strlen(name))
                {
                    return i;
             
                }
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
            }
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)