How to do...
#1

I want to check if strlen(tmp1)'s text = x. How could I do that? I have this (doesn't work):

pawn Код:
if(strlen(tmp1)="x")
Whole script

pawn Код:
if(strcmp(cmd, "/velocity", true)==0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid, 0xFF0000AA, "You can only use this command while driving a vehicle!");
            return 1;
        }
        new tmp1[256], tmp2[256];
        tmp1= strtok(cmdtext, idx);
        tmp2= strtok(cmdtext, idx);
        if(!strlen(tmp1) || !strlen(tmp2))
        {
            SendClientMessage(playerid, LIGHTBLUE2, "Use: /velocity [x/y/z] [value]");
            SendClientMessage(playerid, orange, "Function: Velocity weeha pr0n0");
            return 1;
        }
       
        if(strlen(tmp1)="x") <-- Line 6557
        {

            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                GetVehicleVelocity(GetPlayerVehicleID(playerid), xpos, ypos, zpos);
                SetVehicleVelocity(GetPlayerVehicleID(playerid), xpos, ypos, zvelovalue);
            }
            else
            {
                InCar[playerid] = false;
                GetPlayerVelocity(playerid, xpos, ypos, zpos);
                SetPlayerVelocity(playerid, xpos, ypos, zvelovalue);
            }
        }
        return 1;
    }
Errors/warnings:

pawn Код:
C:\Users\Robin\samp03asvr_R7_win32\gamemodes\MS.pwn(6557) : warning 211: possibly unintended assignment
C:\Users\Robin\samp03asvr_R7_win32\gamemodes\MS.pwn(6557) : error 022: must be lvalue (non-constant)
C:\Users\Robin\samp03asvr_R7_win32\gamemodes\MS.pwn(6557) : warning 215: expression has no effect
C:\Users\Robin\samp03asvr_R7_win32\gamemodes\MS.pwn(6557) : error 001: expected token: ";", but found ")"
C:\Users\Robin\samp03asvr_R7_win32\gamemodes\MS.pwn(6557) : error 029: invalid expression, assumed zero
C:\Users\Robin\samp03asvr_R7_win32\gamemodes\MS.pwn(6557) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664              Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

I think this code i give u is correct..
Код:
if(strcmp(cmd, "/velocity", true)==0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid, 0xFF0000AA, "You can only use this command while driving a vehicle!");
            return 1;
        }
        new tmp1[256], tmp2[256];
        tmp1= strtok(cmdtext, idx);
        tmp2= strtok(cmdtext, idx);
        if(!strlen(tmp1) || !strlen(tmp2))
        {
            SendClientMessage(playerid, LIGHTBLUE2, "Use: /velocity [x/y/z] [value]");
            SendClientMessage(playerid, orange, "Function: Velocity weeha pr0n0");
            return 1;
        }
       
        if(strlen(tmp1) == "x") <-- Line 6557
        {

            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                GetVehicleVelocity(GetPlayerVehicleID(playerid), xpos, ypos, zpos);
                SetVehicleVelocity(GetPlayerVehicleID(playerid), xpos, ypos, zvelovalue);
            }
            else
            {
                InCar[playerid] = false;
                GetPlayerVelocity(playerid, xpos, ypos, zpos);
                SetPlayerVelocity(playerid, xpos, ypos, zvelovalue);
            }
        }
        return 1;
    }
Reply
#3

Код:
if(strcmp(cmd, "/velocity", true)==0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid, 0xFF0000AA, "You can only use this command while driving a vehicle!");
            return 1;
        }
        new tmp1[256], tmp2[256];
        tmp1= strtok(cmdtext, idx);
        tmp2= strtok(cmdtext, idx);
        if(!strlen(tmp1) || !strlen(tmp2))
        {
            SendClientMessage(playerid, LIGHTBLUE2, "Use: /velocity [x/y/z] [value]");
            SendClientMessage(playerid, orange, "Function: Velocity weeha pr0n0");
            return 1;
        }
       
        if(!strcmp(tmp1, "x", true)) <-- Line 6557
        {

            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                GetVehicleVelocity(GetPlayerVehicleID(playerid), xpos, ypos, zpos);
                SetVehicleVelocity(GetPlayerVehicleID(playerid), xpos, ypos, zvelovalue);
            }
            else
            {
                InCar[playerid] = false;
                GetPlayerVelocity(playerid, xpos, ypos, zpos);
                SetPlayerVelocity(playerid, xpos, ypos, zvelovalue);
            }
        }
        return 1;
    }
Reply
#4

EDIT:

NVM, carltons works.. Tyy
Reply
#5

Quote:
Originally Posted by RobinOwnz
Посмотреть сообщение
pawn Код:
C:\Users\Robin\samp03asvr_R7_win32\gamemodes\MS.pwn(6557) : error 033: array must be indexed (variable "-unknown-")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Look at my code, it should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)