Help on a command: /front <x,y or z> <amount>
#1

I've tried to making a command, which would move player according with the params you'd choose, and the amount. like:
Код:
/front x 10 // Would move player X pos + 10
Can anyone tell me what's wrong?
pawn Код:
dcmd_front(playerid,params[])
{
     new pos,amount;
     new tmp[256],Index;
     tmp = strtok(params, Index);
     pos = strval(params);
     amount = strval(tmp);
     if(!strlen(params) || !strval(tmp)) return SendClientMessage(playerid, color, "USAGE: /front <x,y,z> <amount");
     new Float:Posx,Float:Posy,Float:Posz;
     GetPlayerPos(playerid, Posx, Posy, Posz);
     if(!strcmp(params,"x",true) && strval(tmp))
     {
         SetPlayerPos(playerid, Posx+amount,Posy,Posz);
     }
     else if(!strcmp(params,"y",true) && strval(tmp))
     {
         SetPlayerPos(playerid, Posx,Posy+amount,Posz);
     }
     else if(!strcmp(params,"z",true) && strval(tmp))
     {
         SetPlayerPos(playerid, Posx,Posy,Posz+amount);
     }
     else
     {
         SendClientMessage(playerid, color, "You can only choose: x, y or z");
     }
     return 1;
}
Off-topic: Could anyone help me on my topic ( I didn't bump. It were over 12h since I made the topic). Here the link:
Click here
Reply
#2

First you tell me what's the problem, then I can try help you find out what's wrong.
Reply
#3

Oh, sorry. It keeps giving me:
Код:
USAGE: /front <x,y,z> <amount
Reply
#4

pawn Код:
dcmd_front(playerid,params[])
{
    new pos[4], amount;
    new tmp[128], Index;
    tmp = strtok(params, Index);
    format(pos, sizeof(pos), "%s", tmp);
    tmp = strtok(params, Index);
    amount = strval(tmp);
    if(!strlen(params) || !strlen(tmp)) return SendClientMessage(playerid, color, "USAGE: /front <x,y,z> <amount");
    new Float:Posx,Float:Posy,Float:Posz;
    GetPlayerPos(playerid, Posx, Posy, Posz);
    if(!strcmp(pos,"x",true))
    {
        SetPlayerPos(playerid, Posx+amount,Posy,Posz);
    }
    else if(!strcmp(pos,"y",true))
    {
        SetPlayerPos(playerid, Posx,Posy+amount,Posz);
    }
    else if(!strcmp(pos,"z",true))
    {
        SetPlayerPos(playerid, Posx,Posy,Posz+amount);
    }
    else
    {
        SendClientMessage(playerid, color, "You can only choose: x, y or z");
    }
    return 1;
}
Reply
#5

Thanks mademan.
Reply
#6

Oh nvm then
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)