(UNSOLVED) Basic Command
#1

I want that when some1 do /evento [motos-amatar-autos-carrera]
works
like /evento motos & do something
/evento amatar & do something

pawn Code:
if(strcmp(cmd, "/evento", true) == 0)
 {
        new botcmd;
        tmp = strtok(cmdtext, idx);
        if(!IsPlayerAdmin(playerid))
        {
            SendClientMessage(playerid, COLOR_YELLOW, "Necesitas ser RCON!");
            return 1;
        }
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento motos");
            SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento amatar");
            SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento autos");
            SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento carrera");
            return 1;
        }
Reply
#2

oh like a /me command so i type /me types /me xD it says Zonoya Types /me xD?

Also can u translate the command to english plz
Reply
#3

No

Like /evento has different options
You can choose between all those 4

Like /evento cars
.SetPlayerPos to 2132131.23 w/e

And like /evento amatar
SetPlayerCash To blah blah

So if the players just do /evento
then send a message "You didnt type it correct this are the options /evento matar /evento motos /evento autos
Reply
#4

hmm i dont think i can do that you're just gonna have to wait for other scripters sorry
Reply
#5

pawn Code:
if(strcmp(cmd, "/evento", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        new eventid[20];
        tmp = strtok(cmdtext, idx);
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Necesitas ser RCON!");
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, -1, "Usage: /evento motos");
            SendClientMessage(playerid, -1, "Usage: /evento amatar");
            SendClientMessage(playerid, -1, "Usage: /evento autos");
            SendClientMessage(playerid, -1, "Usage: /evento carrera");
            return 1;
        }
        strmid(eventid, tmp, 0, strlen(cmdtext), 255);
        if(strcmp(eventid, "motos", true, strlen(eventid)) == 0)
        {
            // Do your motos code
        }
        else if(strcmp(eventid, "amatar", true, strlen(eventid)) == 0)
        {
            // Do your amatar code
        }
        else if(strcmp(eventid, "autos", true, strlen(eventid)) == 0)
        {
            // Do your autos code
        }
        else if(strcmp(eventid, "carrera", true, strlen(eventid)) == 0)
        {
            // Do your carrera code
        }
        else return SendClientMessage(playerid, -1,"Unkown parameter! [Motos, Amatar, Autos, Carrera]");
    }
    return 1;
}
Reply
#6

pawn Code:
C:\Users\Alex\Desktop\Untitled.pwn(91) : error 017: undefined symbol "cmd"
C:\Users\Alex\Desktop\Untitled.pwn(96) : error 017: undefined symbol "tmp"
C:\Users\Alex\Desktop\Untitled.pwn(96) : error 017: undefined symbol "strtok"
C:\Users\Alex\Desktop\Untitled.pwn(98) : error 017: undefined symbol "tmp"
C:\Users\Alex\Desktop\Untitled.pwn(106) : error 017: undefined symbol "tmp"
C:\Users\Alex\Desktop\Untitled.pwn(127) : warning 217: loose indentation
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
Reply
#7

pawn Code:
if(strcmp(cmd, "/evento", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        new eventid[20], tmp[128];
        tmp = strtok(cmdtext, idx);
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Necesitas ser RCON!");
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, -1, "Usage: /evento motos");
            SendClientMessage(playerid, -1, "Usage: /evento amatar");
            SendClientMessage(playerid, -1, "Usage: /evento autos");
            SendClientMessage(playerid, -1, "Usage: /evento carrera");
            return 1;
        }
        strmid(eventid, tmp, 0, strlen(cmdtext), 255);
        if(strcmp(eventid, "motos", true, strlen(eventid)) == 0)
        {
            // Do your motos code
        }
        else if(strcmp(eventid, "amatar", true, strlen(eventid)) == 0)
        {
            // Do your amatar code
        }
        else if(strcmp(eventid, "autos", true, strlen(eventid)) == 0)
        {
            // Do your autos code
        }
        else if(strcmp(eventid, "carrera", true, strlen(eventid)) == 0)
        {
            // Do your carrera code
        }
        else return SendClientMessage(playerid, -1,"Unkown parameter! [Motos, Amatar, Autos, Carrera]");
    }
    return 1;
}
Reply
#8

pawn Code:
C:\Users\Alex\Desktop\Untitled.pwn(65) : error 017: undefined symbol "cmd"
C:\Users\Alex\Desktop\Untitled.pwn(70) : error 017: undefined symbol "strtok"
C:\Users\Alex\Desktop\Untitled.pwn(70) : error 033: array must be indexed (variable "tmp")
C:\Users\Alex\Desktop\Untitled.pwn(101) : warning 217: loose indentation
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Can some one fix it or convert it to sscanf.
Reply
#9

Mark those lines with "//" and post your script here.
Reply
#10

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
//if(strcmp(cmd, "/evento", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        new eventid[20], tmp[128];
 //       tmp = strtok(cmdtext, idx);
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Necesitas ser RCON!");
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, -1, "Usage: /evento motos");
            SendClientMessage(playerid, -1, "Usage: /evento amatar");
            SendClientMessage(playerid, -1, "Usage: /evento autos");
            SendClientMessage(playerid, -1, "Usage: /evento carrera");
            return 1;
        }
        strmid(eventid, tmp, 0, strlen(cmdtext), 255);
        if(strcmp(eventid, "motos", true, strlen(eventid)) == 0)
        {
            // Do your motos code
        }
        else if(strcmp(eventid, "amatar", true, strlen(eventid)) == 0)
        {
            // Do your amatar code
        }
        else if(strcmp(eventid, "autos", true, strlen(eventid)) == 0)
        {
            // Do your autos code
        }
        else if(strcmp(eventid, "carrera", true, strlen(eventid)) == 0)
        {
            // Do your carrera code
        }
        else return SendClientMessage(playerid, -1,"Unkown parameter! [Motos, Amatar, Autos, Carrera]");
    }
    return 1;
}
//  return 0;
}
Reply
#11

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmd, "/evento", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new eventid[20], tmp[128];
            tmp = strtok(cmdtext, idx);
            if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Necesitas ser RCON!");
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, -1, "Usage: /evento motos");
                SendClientMessage(playerid, -1, "Usage: /evento amatar");
                SendClientMessage(playerid, -1, "Usage: /evento autos");
                SendClientMessage(playerid, -1, "Usage: /evento carrera");
                return 1;
            }
            strmid(eventid, tmp, 0, strlen(cmdtext), 255);
            if(strcmp(eventid, "motos", true, strlen(eventid)) == 0)
            {
                // Do your motos code
            }
            else if(strcmp(eventid, "amatar", true, strlen(eventid)) == 0)
            {
                // Do your amatar code
            }
            else if(strcmp(eventid, "autos", true, strlen(eventid)) == 0)
            {
                // Do your autos code
            }
            else if(strcmp(eventid, "carrera", true, strlen(eventid)) == 0)
            {
                // Do your carrera code
            }
            else return SendClientMessage(playerid, -1,"Unkown parameter! [Motos, Amatar, Autos, Carrera]");
        }
        return 1;
    }
    return 0;
}
At the end of your script.
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;
}
Reply
#12

pawn Code:
C:\Users\Alex\Desktop\Untitled.pwn(64) : error 017: undefined symbol "cmd"
C:\Users\Alex\Desktop\Untitled.pwn(69) : error 017: undefined symbol "idx"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Reply
#13

new tmp[128];

and change cmd to cmdtext
Reply
#14

pawn Code:
C:\Users\Alex\Desktop\Untitled.pwn(69) : error 017: undefined symbol "idx"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#15

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/evento", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new eventid[20], tmp[128], idx;
            tmp = strtok(cmdtext, idx);
            if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Necesitas ser RCON!");
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, -1, "Usage: /evento motos");
                SendClientMessage(playerid, -1, "Usage: /evento amatar");
                SendClientMessage(playerid, -1, "Usage: /evento autos");
                SendClientMessage(playerid, -1, "Usage: /evento carrera");
                return 1;
            }
            strmid(eventid, tmp, 0, strlen(cmdtext), 255);
            if(strcmp(eventid, "motos", true, strlen(eventid)) == 0)
            {
                // Do your motos code
            }
            else if(strcmp(eventid, "amatar", true, strlen(eventid)) == 0)
            {
                // Do your amatar code
            }
            else if(strcmp(eventid, "autos", true, strlen(eventid)) == 0)
            {
                // Do your autos code
            }
            else if(strcmp(eventid, "carrera", true, strlen(eventid)) == 0)
            {
                // Do your carrera code
            }
            else return SendClientMessage(playerid, -1,"Unkown parameter! [Motos, Amatar, Autos, Carrera]");
        }
        return 1;
    }
    return 0;
}
Reply
#16

pawn Code:
C:\Users\Alex\Desktop\Untitled.pwn(64) : error 029: invalid expression, assumed zero
C:\Users\Alex\Desktop\Untitled.pwn(64) : error 029: invalid expression, assumed zero
C:\Users\Alex\Desktop\Untitled.pwn(65) : warning 217: loose indentation
C:\Users\Alex\Desktop\Untitled.pwn(71) : error 017: undefined symbol "strtok"
C:\Users\Alex\Desktop\Untitled.pwn(71) : error 033: array must be indexed (variable "tmp")
C:\Users\Alex\Desktop\Untitled.pwn(72) : error 079: inconsistent return types (array & non-array)
C:\Users\Alex\Desktop\Untitled.pwn(79) : error 079: inconsistent return types (array & non-array)
C:\Users\Alex\Desktop\Untitled.pwn(98) : error 079: inconsistent return types (array & non-array)
C:\Users\Alex\Desktop\Untitled.pwn(100) : error 079: inconsistent return types (array & non-array)
C:\Users\Alex\Desktop\Untitled.pwn(102) : error 079: inconsistent return types (array & non-array)
C:\Users\Alex\Desktop\Untitled.pwn(104) : error 017: undefined symbol "strtok"
C:\Users\Alex\Desktop\Untitled.pwn(104) : error 029: invalid expression, assumed zero
C:\Users\Alex\Desktop\Untitled.pwn(104) : error 017: undefined symbol "string"
C:\Users\Alex\Desktop\Untitled.pwn(104) : fatal error 107: too many error messages on one line

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

pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#define FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/evento", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new eventid[20], tmp[128], idx;
            tmp = strtok(cmdtext, idx);
            if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Necesitas ser RCON!");
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, -1, "Usage: /evento motos");
                SendClientMessage(playerid, -1, "Usage: /evento amatar");
                SendClientMessage(playerid, -1, "Usage: /evento autos");
                SendClientMessage(playerid, -1, "Usage: /evento carrera");
                return 1;
            }
            strmid(eventid, tmp, 0, strlen(cmdtext), 255);
            if(strcmp(eventid, "motos", true, strlen(eventid)) == 0)
            {
                // Do your motos code
            }
            else if(strcmp(eventid, "amatar", true, strlen(eventid)) == 0)
            {
                // Do your amatar code
            }
            else if(strcmp(eventid, "autos", true, strlen(eventid)) == 0)
            {
                // Do your autos code
            }
            else if(strcmp(eventid, "carrera", true, strlen(eventid)) == 0)
            {
                // Do your carrera code
            }
            else return SendClientMessage(playerid, -1,"Unkown parameter! [Motos, Amatar, Autos, Carrera]");
        }
        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;
}
Reply
#17

pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#define FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/evento", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new eventid[20], tmp[128], idx;
            tmp = strtok(cmdtext, idx);
            if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Necesitas ser RCON!");
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, -1, "Usage: /evento motos");
                SendClientMessage(playerid, -1, "Usage: /evento amatar");
                SendClientMessage(playerid, -1, "Usage: /evento autos");
                SendClientMessage(playerid, -1, "Usage: /evento carrera");
                return 1;
            }
            strmid(eventid, tmp, 0, strlen(cmdtext), 255);
            if(strcmp(eventid, "motos", true, strlen(eventid)) == 0)
            {
                // Do your motos code
            }
            else if(strcmp(eventid, "amatar", true, strlen(eventid)) == 0)
            {
                // Do your amatar code
            }
            else if(strcmp(eventid, "autos", true, strlen(eventid)) == 0)
            {
                // Do your autos code
            }
            else if(strcmp(eventid, "carrera", true, strlen(eventid)) == 0)
            {
                // Do your carrera code
            }
            else return SendClientMessage(playerid, -1,"Unkown parameter! [Motos, Amatar, Autos, Carrera]");
        }
        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;
}
Dude, watch out with copying stuff.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)