Some problems.
#1

I'm working on a new script and I have some very simple cmds in like /ak, /deagle, /chainsaw, etc.

Now I get in game and this is what happens:






this is the script part:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/ak", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,30,10000);
        return 1;
    }
    if (strcmp("/m4", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,31,10000);
        return 1;
    }
    if (strcmp("/deagle", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,24,10000);
        return 1;
    }
    if (strcmp("/spas", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,27,10000);
        return 1;
    }
    if (strcmp("/chainsaw", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,9,1);
        return 1;
    }
    if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
        SetPlayerHealth(playerid, 0);
        return 1;
    }
    if (strcmp("/sniper", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,34,10000);
        return 1;
    }
    if (strcmp("/abcdefghijklmnopqrstuvwxyz", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,38,10000);
        return 1;
    }
    if (strcmp("/airportdm", cmdtext, true, 10) == 0)
    {
		SetPlayerPos(playerid,1921.8000488281,-2292.6999511719,15);
        return 1;
    }
    if (strcmp("/9mm", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,22,10000);
        return 1;
    }
    if (strcmp("/shotty", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,25,10000);
        return 1;
    }
    if (strcmp("/mp5", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,29,10000);
        return 1;
    }
    if (strcmp("/rifle", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,33,10000);
        return 1;
    }
    return 0;
}
None of these work and there is no errors in pawno.
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/ak", cmdtext, true, 2) == 0)
    {
        GivePlayerWeapon(playerid,30,10000);
        return 1;
    }
    if (strcmp("/m4", cmdtext, true, 2) == 0)
    {
        GivePlayerWeapon(playerid,31,10000);
        return 1;
    }
    if (strcmp("/deagle", cmdtext, true, 6) == 0)
    {
        GivePlayerWeapon(playerid,24,10000);
        return 1;
    }
    if (strcmp("/spas", cmdtext, true, 4) == 0)
    {
        GivePlayerWeapon(playerid,27,10000);
        return 1;
    }
    if (strcmp("/chainsaw", cmdtext, true, 8) == 0)
    {
        GivePlayerWeapon(playerid,9,1);
        return 1;
    }
    if (strcmp("/kill", cmdtext, true, 4) == 0)
    {
        SetPlayerHealth(playerid, 0);
        return 1;
    }
    if (strcmp("/sniper", cmdtext, true, 6) == 0)
    {
        GivePlayerWeapon(playerid,34,10000);
        return 1;
    }
    if (strcmp("/abcdefghijklmnopqrstuvwxyz", cmdtext, true, 26) == 0)
    {
        GivePlayerWeapon(playerid,38,10000);
        return 1;
    }
    if (strcmp("/airportdm", cmdtext, true, 9) == 0)
    {
        SetPlayerPos(playerid,1921.8000488281,-2292.6999511719,15);
        return 1;
    }
    if (strcmp("/9mm", cmdtext, true, 3) == 0)
    {
        GivePlayerWeapon(playerid,22,10000);
        return 1;
    }
    if (strcmp("/shotty", cmdtext, true, 6) == 0)
    {
        GivePlayerWeapon(playerid,25,10000);
        return 1;
    }
    if (strcmp("/mp5", cmdtext, true, 3) == 0)
    {
        GivePlayerWeapon(playerid,29,10000);
        return 1;
    }
    if (strcmp("/rifle", cmdtext, true, 5) == 0)
    {
        GivePlayerWeapon(playerid,33,10000);
        return 1;
    }
    return 0;
}
Reply
#3

Hmm. Didn't seem to work. Could it be because of includes at the top?

I have one zcmd cmd and it works


Код:
COMMAND:v(playerid, params[])
{
    new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
        new vin;
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        vin=CreateVehicle(vehicleid, x, y, z, 0.0, color1, color2, -1);
        PutPlayerInVehicle(playerid, vin, 0);
    }else{
        SendClientMessage(playerid, COLOR_GREY, "ERROR: This command requires: /v [vehicleid][color1][color2]");
    }
    return 1;
}
Reply
#4

You can't use zcmd like that with onplayercommandtext. However - https://sampforum.blast.hk/showthread.php?tid=276063
Reply
#5

The zcmd is at the bottom of my script. It is not near the OnPlayerCommandText
Reply
#6

Wait nogh you could convert your strcmp cmds to zcmd because zcmd is more easier than strcmp
Reply
#7

A big mistake that I have seen thousand times.
Many people use it like this
pawn Код:
if (strcmp("/command", cmdtext, true, 10) == 0)
in many commands.
For example:
pawn Код:
if (strcmp("/ak", cmdtext, true, 10) == 0)

// Or

if (strcmp("/ak", cmdtext, true, 2) == 0)
Isn't 2 or 10. It's
pawn Код:
if (strcmp("/ak", cmdtext, true, 3) == 0)
".." / >1 || a >2 || k >3
Reply
#8

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
Wait nogh you could convert your strcmp cmds to zcmd because zcmd is more easier than strcmp
Could you show me how to do it. Like do the /ak one so i can see how it is done and then i can convert all of them.
Reply
#9

Quote:
Originally Posted by nogh445
Посмотреть сообщение
Could you show me how to do it. Like do the /ak one so i can see how it is done and then i can convert all of them.
pawn Код:
if (strcmp("/ak", cmdtext, true, 2) == 0)
    {
        GivePlayerWeapon(playerid,30,10000);
        return 1;
    }
Would be:

pawn Код:
CMD:ak(playerid, params[])
{
    if ( isnull ( params ) ) GivePlayerWeapon( playerid, 30, 10000 );
    return 1;
}
Reply
#10

Quote:
Originally Posted by SmiT
Посмотреть сообщение
pawn Код:
if (strcmp("/ak", cmdtext, true, 2) == 0)
    {
        GivePlayerWeapon(playerid,30,10000);
        return 1;
    }
Would be:

pawn Код:
CMD:ak(playerid, params[])
{
    if ( isnull ( params ) ) GivePlayerWeapon( playerid, 30, 10000 );
    return 1;
}
Well a easy way would be
pawn Код:
CMD:ak(playerid, params[])
{
    GivePlayerWeapon( playerid, 30, 10000 );
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)