Help with this command.
#1

Hi, i'm a little new in this world of pawno, i need help with a command to make when i write /pgun , i need to be crouch if not a text warns me " you need to be crouch to pick the gun " , i know is too much to ask but i need help please. i put the code here thanks.

pawn Код:
if(strcmp(cmdtext, "/pickupgun", true) == 0
    || strcmp(cmdtext, "/pgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new f = Mnew a = 0; a < MAX_OBJ; a++)
        {AX_OBJ+1;
        for(
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "No estas cerca del arma que quieres agarrar!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "* Recogiste un arma del suelo: %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
    return 0;
}
Reply
#2

Anywhere on your gamemode:
Код:
stock bool:IsPlayerCrouching(playerid)
{
    new animlib[32];
	new animname[32];
    GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
    return (!strcmp(animname,"WEAPON_CROUCH",false)||!strcmp(animname,"GUNCROUCHFWD",false)||!strcmp(animname,"GUNCROUCHBWD",false)||!strcmp(animlib,"PYTHON",false));
}
(code taken from CRF Library)

Код:
if(strcmp(cmdtext, "/pickupgun", true) == 0
    || strcmp(cmdtext, "/pgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        if(!IsPlayerCrouching(playerid)) return SendClientMessage(playerid,-1,"You must be crouched to pick up weapons.");
        new f = Mnew a = 0; a < MAX_OBJ; a++)
        {AX_OBJ+1;
        for(
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "No estas cerca del arma que quieres agarrar!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "* Recogiste un arma del suelo: %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
    return 0;
}
Reply
#3

Thanks for helping me , the first code work perfectly , but the second code give me a error :

pawn Код:
if(strcmp(cmdtext, "/pickupgun", true) == 0
    || strcmp(cmdtext, "/pgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        if(!IsPlayerCrouching(playerid)) return SendClientMessage(playerid,-1,"You must be crouched to pick up weapons.");
        new f = Mnew a = 0; a < MAX_OBJ; a++) <<<<<<<<<<<<<<<<< THIS LINE
        {AX_OBJ+1;
        for(
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "No estas cerca del arma que quieres agarrar!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "* Recogiste un arma del suelo: %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
    return 0;
}

pawn Код:
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(137) : warning 217: loose indentation
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : error 017: undefined symbol "Mnew"
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : error 017: undefined symbol "a"
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : warning 215: expression has no effect
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : error 017: undefined symbol "a"
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : 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
#4

Quote:
Originally Posted by gamersx
Посмотреть сообщение
Thanks for helping me , the first code work perfectly , but the second code give me a error :

pawn Код:
if(strcmp(cmdtext, "/pickupgun", true) == 0
    || strcmp(cmdtext, "/pgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        if(!IsPlayerCrouching(playerid)) return SendClientMessage(playerid,-1,"You must be crouched to pick up weapons.");
        new f = Mnew a = 0; a < MAX_OBJ; a++) <<<<<<<<<<<<<<<<< THIS LINE
        {AX_OBJ+1;
        for(
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "No estas cerca del arma que quieres agarrar!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "* Recogiste un arma del suelo: %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
    return 0;
}

pawn Код:
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(137) : warning 217: loose indentation
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : error 017: undefined symbol "Mnew"
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : error 017: undefined symbol "a"
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : warning 215: expression has no effect
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : error 017: undefined symbol "a"
C:\Users\gabriel\Desktop\RP SERVER ENEMIGO\filterscripts\DropGun_death.pwn(142) : 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.
pawn Код:
if(strcmp(cmdtext, "/pickupgun", true) == 0
    || strcmp(cmdtext, "/pgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        if(!IsPlayerCrouching(playerid)) return SendClientMessage(playerid,-1,"You must be crouched to pick up weapons.");
        new f;
        for(new a = 0; a < MAX_OBJ; a++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "No estas cerca del arma que quieres agarrar!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "* Recogiste un arma del suelo: %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
    return 0;
Reply
#5

I put the code you give me and still more errors, i give you the pwn please , sorry for this .
Reply
#6

pawn Код:
if(strcmp(cmdtext, "/tomar", true) == 0
    || strcmp(cmdtext, "/pgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        if(!IsPlayerCrouching(playerid)) return SendClientMessage(playerid,-1,"You must be crouched!");
        new f = MAX_OBJ+1;
        for(new a = 0; a < MAX_OBJ; a++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                f = a;
                break;
            }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "No estas cerca del arma que quieres agarrar!");
        DestroyObject(dGunData[f][ObjID]);
        GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        dGunData[f][ObjPos][0] = 0.0;
        dGunData[f][ObjPos][1] = 0.0;
        dGunData[f][ObjPos][2] = 0.0;
        dGunData[f][ObjID] = -1;
        //dGunData[f][ObjData][0] = 0;
        dGunData[f][ObjData][1] = 0;
        new buffer[50];
        format(buffer, sizeof(buffer), "* Recogiste un arma del suelo: %s", GunNames[dGunData[f][ObjData][0]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
        return 1;
    }
This code gives me no errors whatsoever
Reply
#7

Yes!, is working just thank you for your time thanks you , you really help me!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)