if you're tired of it, dont reply
#1

Somehow I just can't finish kinda all of my cmds, I always have something wrong or anything else.
Anyways For the people who are tired of my threads, don't reply then. for the people who wants to help me (appreciated)

I just don't know what I need to add to give the player a weapon.
when I do /giveweapon 1 24 500, it says to the player "You received a weapon" while he doesn't got that weapon.
I know its something with (strcmp but I'm not sure.

PHP код:
CMD:giveweapon(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"SERVER: Unknown command.");
    new 
idtargetweaponidammo;
    
    if(
sscanf(params"ui"idtargetweaponidammo)) return SendClientMessage(playeridCOLOR_WARN"USAGE: /giveweapon [ID] [weaponid] [amount]");
    if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Invalid playerid!");
    
    if(
id == playerid) return SendClientMessage(playeridCOLOR_RED"You already can give yourself any weapons!");
    
    
GivePlayerWeapon(target);
    
    
SendClientMessage(playeridCOLOR_WARN"You gave a weapon!");
    
SendClientMessage(playeridCOLOR_LIGHTBLUE"You received a weapon!");
    return 
1;

Reply
#2

This is something i done for some times ago :

pawn Код:
// Removed

/** Just know to where use targetid and playerid */
Reply
#3

iFarbod,your codes clearly says that it'll give errors to saffierr.He'll get undefined errors.
saffierr post all your error codes.
Reply
#4

I don't have any errors, I want that if a admin types /giveweapon [ID] [weaponid] [amount], that the player gets the weapon. but the player doesn't get the weapon, just a message wich says "You received a weapon"
Reply
#5

You have created the most wierdest variables that don't even match your code...
Learn from this and always remember to use targetid and playerid, or your code will just fuckup.

PHP код:
CMD:giveweapon(playeridparams[]) 

    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"SERVER: Unknown command."); 
    new 
targetidweaponidammo
     
    if(
sscanf(params"udd"targetidweaponidammo)) return SendClientMessage(playeridCOLOR_WARN"USAGE: /giveweapon [targetid] [weaponid] [amount]"); 
    if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Invalid playerid!"); 
     
    if(
targetid == playerid) return SendClientMessage(playeridCOLOR_RED"You already can give yourself any weapons!"); 
     
    
GivePlayerWeapon(targetidweaponidammo); 
     
    
SendClientMessage(playeridCOLOR_WARN"You gave a weapon!"); 
    
SendClientMessage(targetidCOLOR_LIGHTBLUE"You received a weapon!"); 
    return 
1

Reply
#6

HERE Try this
Код:
CMD:giveweapon(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "SERVER: Unknown command."); 
	    new targetid,gun,ammo;if(sscanf(params,"uii",targetid,gun,ammo)) return SendClientMessage(playerid, COLOR_RED, Usage: /Givegun [PlayerID] [Gun] [Ammo]");
	GivePlayerWeapon(targetid, gun, ammo);
}
return 1;
Reply
#7

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Somehow I just can't finish kinda all of my cmds, I always have something wrong or anything else.
Anyways For the people who are tired of my threads, don't reply then. for the people who wants to help me (appreciated)

I just don't know what I need to add to give the player a weapon.
when I do /giveweapon 1 24 500, it says to the player "You received a weapon" while he doesn't got that weapon.
I know its something with (strcmp but I'm not sure.

PHP код:
CMD:giveweapon(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"SERVER: Unknown command.");
    new 
idtargetweaponidammo;
    
    if(
sscanf(params"ui"idtargetweaponidammo)) return SendClientMessage(playeridCOLOR_WARN"USAGE: /giveweapon [ID] [weaponid] [amount]");
    if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Invalid playerid!");
    
    if(
id == playerid) return SendClientMessage(playeridCOLOR_RED"You already can give yourself any weapons!");
    
    
GivePlayerWeapon(target);
    
    
SendClientMessage(playeridCOLOR_WARN"You gave a weapon!");
    
SendClientMessage(playeridCOLOR_LIGHTBLUE"You received a weapon!");
    return 
1;

Go read a tutorial and documentation about sscanf. You're defining variables in sscanf that don't exist without actually defining them and using them.

When you create a command, think about what parameters you need.

In this case, it's giveweapon. So, you need a target, a weapon id, and the amount of ammo.
There fore, you need 3 variables: target, weapon ammo.
There fore, you need to define 3 parameters in sscanf.

pawn Код:
new target, weapon, ammo;
if(sscanf(params, "udd", target, weapon, ammo)) //send client message
D and i are both integers / numeric.

Now you have a target, a weapon, and ammo. When checking the status of the player you are giving the weapon to, use "target" (target does not have to be target, it can be whatever you want it to be, like receiver, or targetid). The weaponid will be obviously "weapon", and the amount of ammo will be "ammo", so you would end up with something like:

pawn Код:
GivePlayerWeapon(target, weapon, ammo);
So if you done:
Код:
/giveweapon 1 26 64
It would give playerid 1 weaponid 26 with 24 ammo.

But, to be safe, you would need to do checks to make sure it's a valid weapon. I think I've said enough though, so hope that helps.
Reply
#8

wauw, THANKS ALL, I AM SOMETIMES STUPID.
you guys totally are open to help! Thanks.
I know now wich variables BUT 1 THING
is it weapon or weaponid?
Reply
#9

Quote:
Originally Posted by saffierr
Посмотреть сообщение
wauw, THANKS ALL, I AM SOMETIMES STUPID.
you guys totally are open to help! Thanks.
I know now wich variables BUT 1 THING
is it weapon or weaponid?
It's completely up to you, it all depends on what variable you create. So you can have:
pawn Код:
new target, weaponid, ammo;
Or

pawn Код:
new id, weapon, ammo;
It's all up to you, they just have to be the same in your sscanf line.
Reply
#10

ok thanks, btw I did if(sscanf(params, "uii", etc... and it worked, So its up to me if I do "udd" or "uii" I saw.
becuase i is integer and d is decimal , almost the same. right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)