Gate close - MoveObject
#1

I made a command, but when I type / cancels close, the gate does not close and shows the following message:
PHP код:
SendClientMessage(playerid, -1"debug 2"); 
Suppress and the object is not moved, what I did wrong in this command? o / cancel open works, plus / cancels close does not work ..

PHP код:
     if (strcmp(cmd"/cancela"true) == 0)
     {
        new 
x_opcao[256];
         
tmp strtok(cmdtextidx);
         if (!
strlen(tmp)) return SendClientMessage(playerid, -1"USE: /cancela [open/close]");
        if (
strcmp(x_opcao"open"true) == 0)
        {
               if (
GetPlayerOrg(playerid) == && IsPlayerInRangeOfPoint(playerid14.01530.39270, -1451.3508313.17880))
            {
                
MoveObject(Cancela1BPM1530.39270, -1451.3508313.17880+0.0001,   0.00010.000000.0000090.00000);
            }
            return 
1;
        }
        if (
strcmp(x_opcao"close"true) == 0//error
        
{
            if (
GetPlayerOrg(playerid) == && IsPlayerInRangeOfPoint(playerid14.01530.39270, -1451.3508313.17880))
            {
                
MoveObject(Cancela1BPM1530.39270, -1451.3508313.178800.0001,  0.0000089.600000.00000);
            }
            
SendClientMessage(playerid, -1"debug 2");
        }
        return 
1;
    } 
@edit

Up.. please!
Reply
#2

up!
Reply
#3

Then you do not satisfy this statement:
pawn Код:
if (GetPlayerOrg(playerid) == 1 && IsPlayerInRangeOfPoint(playerid, 14.0, 1530.39270, -1451.35083, 13.17880))
GetPlayerOrg(playerid) does not equal 1, or you are not in range.
Reply
#4

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Then you do not satisfy this statement:
pawn Код:
if (GetPlayerOrg(playerid) == 1 && IsPlayerInRangeOfPoint(playerid, 14.0, 1530.39270, -1451.35083, 13.17880))
GetPlayerOrg(playerid) does not equal 1, or you are not in range.
The problem continues ..
Reply
#5

Alright, so you need to add an extra debug line, as the problem can be anywhere.
First set:
Код:
if (strcmp(x_opcao, "close", true) == 0) //error 
        { 
            if (GetPlayerOrg(playerid) == 1 && IsPlayerInRangeOfPoint(playerid, 14.0, 1530.39270, -1451.35083, 13.17880)) 
            { 
                MoveObject(Cancela1BPM, 1530.39270, -1451.35083, 13.17880, 0.0001,  0.00000, 89.60000, 0.00000); 
SendClientMessage(playerid, -1, "moving object");
            } 
            SendClientMessage(playerid, -1, "debug 2"); 
        }
If you don't get 'moving object' then the problem is not in the MoveObject.

Second try:
Код:
if (strcmp(x_opcao, "close", true) == 0) //error 
        { 
            if (IsPlayerInRangeOfPoint(playerid, 14.0, 1530.39270, -1451.35083, 13.17880)) 
            { 
                MoveObject(Cancela1BPM, 1530.39270, -1451.35083, 13.17880, 0.0001,  0.00000, 89.60000, 0.00000); 
SendClientMessage(playerid, -1, "moving object");
            } 
            SendClientMessage(playerid, -1, "debug 2"); 
        }
If you still don't get 'moving object' then the problem is your InRangeOfPoint. If you do get 'moving object' then the problem is with GetPlayerOrg(playerid);

You can figure out what it returns by adding a big format to send it to the client. Or add a printf to display it to the console:
Код:
printf("%d", GetPlayerOrg(playerid));
Reply
#6

pawn Код:
if(strcmp(cmd, "/cancela", true) == 0)
    {
        new tmpvar[6];
        tmpvar = strtok(cmdtext, idx);
        if(!strlen(tmpvar)) return SendClientMessage(playerid, -1, "USE: /cancela [open/close]");
        if(!strcmp(tmpvar, "open", true))
        {
            if(GetPlayerOrg(playerid) == 1 && IsPlayerInRangeOfPoint(playerid, 14.0, 1530.39270, -1451.35083, 13.17880))
                MoveObject(Cancela1BPM, 1530.39270, -1451.35083, 13.17880+0.0001,   0.0001, 0.00000, 0.00000, 90.00000);
        }
        else if(!strcmp(tmpvar, "close", true))
        {
            if(GetPlayerOrg(playerid) == 1 && IsPlayerInRangeOfPoint(playerid, 14.0, 1530.39270, -1451.35083, 13.17880))
                MoveObject(Cancela1BPM, 1530.39270, -1451.35083, 13.17880, 0.0001,  0.00000, 89.60000, 0.00000);
        }
        else SendClientMessage(playerid, -1, "USE: /cancela [open/close]");
        return 1;
    }
I didn't even realise you weren't assigning a value to 'x_opcao', lol.

Strcmp returns false or '0' when either of the strings are empty. That's why you were getting the debug message.
Reply
#7

Reputed! tranks!!


@edit



error:
Код:
C:\Users\2\Desktop\gamemode\gamemodes\2.pwn(24018) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
PHP код:
    if(strcmp(cmd"/cancela"true) == 0)
    {
        new 
tmpvar[6];
        
tmpvar strtok(cmdtextidx); //error <<<
        
if(!strlen(tmpvar)) return SendClientMessage(playerid, -1"USE: /cancela [abrir/fechar]");
        if(!
strcmp(tmpvar"abrir"true))
        {
            if(
GetPlayerOrg(playerid) == && IsPlayerInRangeOfPoint(playerid7.01530.39270, -1451.3508313.17880))
                
MoveObject(Cancela1BPM1530.39270, -1451.3508313.17880+0.0001,   0.00010.000000.0000090.00000);
        }
        else if(!
strcmp(tmpvar"fechar"true))
        {
            if(
GetPlayerOrg(playerid) == && IsPlayerInRangeOfPoint(playerid7.01530.39270, -1451.3508313.17880))
                
MoveObject(Cancela1BPM1530.39270, -1451.3508313.178800.0001,  0.0000089.600000.00000);
        }
        else 
SendClientMessage(playerid, -1"USE: /cancela [abrir/fechar]");
        return 
1;
    } 
Reply
#8

Oh, well that's just 'strtok' being a gay method of using strcmp with parameters. Either switch to ZCMD (recommended), or just change 'new tmpvar[6]', to 'new tmpvar[128]'.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)