/givegun[help]
#1

how can i put a timer so i can /givegun once at 2 minutes??i tried there but no work..

PHP код:
if(strcmp(cmd"/givegun"true) == 0)
                    {
                    if(
IsPlayerConnected(playerid))
                    {
                    
tmp strtok(cmdtextidx);
                    if(!
strlen(tmp))
                    {
                        
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /givegun [playerid/PartOfName] [weaponid(eg. 46 = Parachute)] [ammo]");
                        return 
1;
                    }
                    new 
playa;
                    new 
gun;
                    new 
ammo;
                    
playa ReturnUser(tmp);
                    
tmp strtok(cmdtextidx);
                    
gun strval(tmp);
                    if(!
strlen(tmp))
                    {
                        
SendClientMessage(playeridCOLOR_GRAD1"USAGE: /givegun [playerid/PartOfName] [weaponid] [ammo]");
                        
SendClientMessage(playeridCOLOR_GRAD4"3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 10-13(Dildo) 14(Flowers) 16(Grenades) 18(Molotovs) 22(Pistol) 23(SPistol)");
                        
SendClientMessage(playeridCOLOR_GRAD3"24(Eagle) 25(shotgun) 29(MP5) 30(AK47) 31(M4) 33(Rifle) 34(Sniper) 37(Flamethrower) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
                        return 
1;
                    }
                    if(
gun 1||gun 46||gun==27||gun==1||gun==2||gun==9||gun==19||gun==20||gun==21||gun==36||gun==39||gun==40||gun==44||gun==45)
                    { 
SendClientMessage(playeridCOLOR_GRAD1"   wrong WeaponID!"); return 1; }
                    
tmp strtok(cmdtextidx);
                    
ammo strval(tmp);
                    if(
ammo <1||ammo 999)
                    { 
SendClientMessage(playeridCOLOR_GRAD1"   dont go below 1 or above 999 bullets!"); return 1; }
                    if (
PlayerInfo[playerid][pAdmin] >= 1337)
                    {
                        if(
IsPlayerConnected(playa))
                        {
                            if(
playa != INVALID_PLAYER_ID)
                            {
                                
GivePlayerWeapon(playagunammo);
                                
GetPlayerName(playagiveplayersizeof(giveplayer));
                                
GetPlayerName(playeridsendernamesizeof(sendername));
                                
format(string256"News: %s has given %s gun id %d. dupa %s"giveplayer,sendername,gun);
                                
ABroadCast(COLOR_YELLOW,string,1);
                                
SetTimerEx("gun"300000"i"playerid);
                            }
                        }
                    }
                    else
                    {
                        
SendClientMessage(playeridCOLOR_GRAD1"   you are not authorized to use that command!");
                    }
                    }
                    return 
1;
                    } 
Reply
#2

It is easy.

At the top of your script, place this:

pawn Код:
new GiveGunAllow[MAX_PLAYERS] = 0;
forward gun(playerid);
Under OnPlayerConnect

pawn Код:
new GiveGunAllow[playerid] = 0;
Then, the command:

pawn Код:
if(strcmp(cmd, "/givegun", true) == 0)
                    {
                    if(IsPlayerConnected(playerid))
                    {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /givegun [playerid/PartOfName] [weaponid(eg. 46 = Parachute)] [ammo]");
                        return 1;
                    }
                    new playa;
                    new gun;
                    new ammo;
                    playa = ReturnUser(tmp);
                    tmp = strtok(cmdtext, idx);
                    gun = strval(tmp);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /givegun [playerid/PartOfName] [weaponid] [ammo]");
                        SendClientMessage(playerid, COLOR_GRAD4, "3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 10-13(Dildo) 14(Flowers) 16(Grenades) 18(Molotovs) 22(Pistol) 23(SPistol)");
                        SendClientMessage(playerid, COLOR_GRAD3, "24(Eagle) 25(shotgun) 29(MP5) 30(AK47) 31(M4) 33(Rifle) 34(Sniper) 37(Flamethrower) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
                        return 1;
                    }
                    if(gun < 1||gun > 46||gun==27||gun==1||gun==2||gun==9||gun==19||gun==20||gun==21||gun==36||gun==39||gun==40||gun==44||gun==45)
                    { SendClientMessage(playerid, COLOR_GRAD1, "   wrong WeaponID!"); return 1; }
                    tmp = strtok(cmdtext, idx);
                    ammo = strval(tmp);
                    if(ammo <1||ammo > 999)
                    { SendClientMessage(playerid, COLOR_GRAD1, "   dont go below 1 or above 999 bullets!"); return 1; }
                    if (PlayerInfo[playerid][pAdmin] >= 1337)
                    {
                        if(IsPlayerConnected(playa))
                        {
                            if(playa != INVALID_PLAYER_ID)
                            {
                                if(GiveGunAllow[playerid] == 0)
                                {
                                    GivePlayerWeapon(playa, gun, ammo);
                                    GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                                    GetPlayerName(playerid, sendername, sizeof(sendername));
                                    format(string, 256, "News: %s has given %s gun id %d. dupa %s", giveplayer,sendername,gun);
                                    ABroadCast(COLOR_YELLOW,string,1);
                                    GiveGunAllow[playerid] = 1; //This sets it so the player can't give a gun for 2 minutes.
                                    SetTimerEx("gun", 60000*2, 0, "i", playerid);
                                }
                                else return SendClientMessage(playerid, 0xFFFFFFF, "You can't give a gun for 2 minutes!");
                            }
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
                    }
                    }
                    return 1;
                    }
If you look above, I have added something.

Then, make a public:

pawn Код:
public gun(playerid)
{
    GiveGunAllow[playerid] = 0;
    SendClientMessage(playerid, COLOR_YELLOW, "You can now give a gun again.");
    return 1;
}
Reply
#3

can someone help me with hood and bonnet please

PHP код:
if(strcmp(cmd,"/bonnet",true)==0)
                    {
                    if(!
IsPlayerInAnyVehicle(playerid))
                    {
                    new 
enginelightsalarmdoorsbonnetbootobjective;
                    new 
veh GetPlayerVehicleID(playerid);
                    if(
GetPVarInt(playerid"Bonnet") == 0)
                    {
                    
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
                    
SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
                    
SetPVarInt(playerid"Bonnet"1);
                    }
                    else if(
GetPVarInt(playerid"Bonnet") == 1)
                    {
                    
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
                    
SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
                    
SetPVarInt(playerid"Bonnet"0);
                    }
                    }
                     return 
1;
                     } 
Reply
#4

pawn Код:
if(strcmp(cmd,"/bonnet",true)==0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new engine, lights, alarm, doors, bonnet, boot, objective;
        new veh = GetPlayerVehicleID(playerid);
        if(GetPVarInt(playerid, "Bonnet") == 0)
        {
            GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
            SetPVarInt(playerid, "Bonnet", 1);
        }
        else
        {
            GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
            SetPVarInt(playerid, "Bonnet", 0);
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
pawn Код:
if(strcmp(cmd,"/bonnet",true)==0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new engine, lights, alarm, doors, bonnet, boot, objective;
        new veh = GetPlayerVehicleID(playerid);
        if(GetPVarInt(playerid, "Bonnet") == 0)
        {
            GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
            SetPVarInt(playerid, "Bonnet", 1);
        }
        else
        {
            GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
            SetPVarInt(playerid, "Bonnet", 0);
        }
    }
    return 1;
}
i get warnings you test the code?
Reply
#6

Of course.

This work

What were the warnings?
Reply
#7

mybad how can i do it so i do /veh and /veh bonnet get it?how do i do it?
Reply
#8

I don't understand
Reply
#9

like i type /veh and it appears lights.bonnet.boot get it? i dont want /bonnet i want /veh bonnet?
Reply
#10

pawn Код:
if(strcmp(cmd, "/veh", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
        return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [part]");

    if(!strcmp(tmp,"engine"))
    {
        //functions
    }
    else if(!strcmp(tmp,"lights"))
    {
        //functions
    }
    else if(!strcmp(tmp,"alarm"))
    {
        //functions
    }
    else if(!strcmp(tmp,"doors"))
    {
        //functions
    }
    else if(!strcmp(tmp,"bonnet"))
    {
        //functions
    }
    else if(!strcmp(tmp,"boot"))
    {
        //functions
    }
    else if(!strcmp(tmp,"objective"))
    {
        //functions
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)