I don't know what is wrong.
#1

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/vbite"cmdtexttrue10) == 0)
    {
        new 
Float:xFloat:yFloat:z;
        new 
targetid;
        if(
IsPlayerInRangeOfPoint(targetid,2.0,x,y,z))return SendClientMessage(playerid,0xE00404,"You are not near the player");
        {
            
SetPlayerHealth(targetid,10);
            
SendClientMessage(targetid,0xE00404,"You have been bitten by a vampire");
            
SetPlayerDrunkLevel(playerid,3000);
            
ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01",4.1,0,0,0,0,1,1);
        }
        return 
1;
    }
    return 
0;

This is not giving any error but I want to apply this cmd on others so why is this not working?
Please fix it for me.
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/vbite", cmdtext, true))
    {
        new Float:x, Float:y, Float:z;
        new targetid = cmdtext[9];
        if(IsPlayerInRangeOfPoint(targetid,2.0,x,y,z)) return SendClientMessage(playerid,0xE00404,"You are not near the player");
        SetPlayerHealth(targetid,10);
        SendClientMessage(targetid,0xE00404,"You have been bitten by a vampire");
        SetPlayerDrunkLevel(playerid,3000);
        ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01",4.1,0,0,0,0,1,1);
        return 1;
    }
    return 0;
}
Reply
#3

Quote:
Originally Posted by FireCat
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/vbite", cmdtext, true))
    {
        new Float:x, Float:y, Float:z;
        new targetid = cmdtext[9];
        if(IsPlayerInRangeOfPoint(targetid,2.0,x,y,z)) return SendClientMessage(playerid,0xE00404,"You are not near the player");
        SetPlayerHealth(targetid,10);
        SendClientMessage(targetid,0xE00404,"You have been bitten by a vampire");
        SetPlayerDrunkLevel(playerid,3000);
        ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01",4.1,0,0,0,0,1,1);
        return 1;
    }
    return 0;
}
x, y and z have no value rather than 0, so what's the use of position checking?
Also, there's no actual validation on the parameter that the player inserts.
Additionally, the error message will be sent when the target player IS near the coordinates. I don't think that's the desired behavior.
Reply
#4

try this
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
      new cmd[256], index;
      cmd = strtok(cmdtext,index);
    if (strcmp("/vbite", cmd, true, 10) == 0)
    {
          new tmp[256];
          if(!strlen(tmp) ) return SendClientMessage(playerid,-1,"[USAGE] /vbite [id]");
         
        new Float:x, Float:y, Float:z;
        new targetid;
        targetid = strval(tmp);
        GetPlayerPos(targetid,x,y,z);
       
        if(IsPlayerInRangeOfPoint(playerid,2.0,x,y,z))return SendClientMessage(playerid,0xE00404,"You are not near the player");
        {
            SetPlayerHealth(targetid,10);
            SendClientMessage(targetid,0xE00404,"You have been bitten by a vampire");
            SetPlayerDrunkLevel(playerid,3000);
            ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01",4.1,0,0,0,0,1,1);
        }
        return 1;
    }
    return 0;
}
and wherever you want add this except callbacks
pawn Код:
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;
}
Reply
#5

Quote:
Originally Posted by AndreT
Посмотреть сообщение
x, y and z have no value rather than 0, so what's the use of position checking?
Also, there's no actual validation on the parameter that the player inserts.
Additionally, the error message will be sent when the target player IS near the coordinates. I don't think that's the desired behavior.
In fact, all I did wrong was the coordinates, but aswell HE needs to learn.
I can't do everything...

@topic:
Remove the 'new Float, Float:y,Float:z' from your code.
Reply
#6

Here, just use this...
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

    if (!strcmp("/vbite", cmdtext))
    {
        new Float:x, Float:y, Float:z;
        new targetid = cmdtext[7];

        if(!IsPlayerConnected(targetid))
        {
           SendClientMessage(playerid,0xE00404,"Invalid player id");
           return 1;
        }
        GetPlayerPos(targetid, x, y, z);

        if(IsPlayerInRangeOfPoint(targetid,2.0,x,y,z))
        {
            SetPlayerHealth(targetid,10);
            SendClientMessage(targetid,0xE00404,"You have been bitten by a vampire");
            SetPlayerDrunkLevel(playerid,3000);
            ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01",4.1,0,0,0,0,1,1);
        }
        else
            SendClientMessage(playerid,0xE00404,"You are not near the player");

        return 1;
    }

    return 0;
}
Oh and by the way, if you want the color to be as you expect it to be, add FF to the end (replace with this 0xE00404FF) or its going to be fucked up.
Reply
#7

When I try it,it says Server:UNKOWN COMMAND please fix it for me.
Reply
#8

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

    if (!strcmp("/vbite", cmdtext))
    {
        new Float:x, Float:y, Float:z;
        new targetid = cmdtext[7];

        if(!IsPlayerConnected(targetid))
        {
           SendClientMessage(playerid,0xE00404FF,"Invalid player id");
           return 1;
        }
        GetPlayerPos(targetid, x, y, z);

        if(IsPlayerInRangeOfPoint(playerid,2.0,x,y,z))
        {
            SetPlayerHealth(targetid,10);
            SendClientMessage(targetid,0xE00404FF,"You have been bitten by a vampire");
            SetPlayerDrunkLevel(playerid,3000);
            ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01",4.1,0,0,0,0,1,1);
        }
        else
            SendClientMessage(playerid,0xE00404,"You are not near the player");

        return 1;
    }

    return 0;
}
Reply
#9

try this
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
      new cmd[256], index;
      cmd = strtok(cmdtext,index);
    if (strcmp("/vbite", cmd, true, 10) == 0)
    {
          new tmp[256];
          if(!strlen(tmp) ) return SendClientMessage(playerid,-1,"[USAGE] /vbite [id]");
         
        new Float:x, Float:y, Float:z;
        new targetid;
        targetid = strval(tmp);
        GetPlayerPos(targetid,x,y,z);
       
        if(IsPlayerInRangeOfPoint(playerid,2.0,x,y,z))return SendClientMessage(playerid,0xE00404,"You are not near the player");
        {
            SetPlayerHealth(targetid,10);
            SendClientMessage(targetid,0xE00404,"You have been bitten by a vampire");
            SetPlayerDrunkLevel(playerid,3000);
            ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01",4.1,0,0,0,0,1,1);
        }
        return 1;
    }
    return 0;
}
and wherever you want add this except callbacks
pawn Код:
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;
}
try this is good
Reply
#10

Quote:

try this
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], index;
cmd = strtok(cmdtext,index);
if (strcmp("/vbite", cmd, true, 10) == 0)
{
new tmp[256];
if(!strlen(tmp) ) return SendClientMessage(playerid,-1,"[USAGE] /vbite [id]");

new Float, Float:y, Float:z;
new targetid;
targetid = strval(tmp);
GetPlayerPos(targetid,x,y,z);

if(IsPlayerInRangeOfPoint(playerid,2.0,x,y,z))retu rn SendClientMessage(playerid,0xE00404,"You are not near the player");
{
SetPlayerHealth(targetid,10);
SendClientMessage(targetid,0xE00404,"You have been bitten by a vampire");
SetPlayerDrunkLevel(playerid,3000);
ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01" ,4.1,0,0,0,0,1,1);
}
return 1;
}
return 0;
}

and wherever you want add this except callbacks
pawn Code:
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;
}
try this is good

Every time I use this it says /vbite [id],but does nothing,please any one help me.
Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{

if (!strcmp("/vbite", cmdtext))
{
new Float, Float:y, Float:z;
new targetid = cmdtext[7];

if(!IsPlayerConnected(targetid))
{
SendClientMessage(playerid,0xE00404FF,"Invalid player id");
return 1;
}
GetPlayerPos(targetid, x, y, z);

if(IsPlayerInRangeOfPoint(playerid,2.0,x,y,z))
{
SetPlayerHealth(targetid,10);
SendClientMessage(targetid,0xE00404FF,"You have been bitten by a vampire");
SetPlayerDrunkLevel(playerid,3000);
ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_01" ,4.1,0,0,0,0,1,1);
}
else
SendClientMessage(playerid,0xE00404,"You are not near the player");

return 1;
}

return 0;
}

And for yur it says server unknown command.
Please help anyone.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)