PDA

View Full Version : help me!


ahameed4755
18/09/2015, 09:14 PM
CMD:agiveweapon(playerid,params[])
{
new targetid;
new TargetID,Weapon,Ammo;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFF,"you are not rcon admin");
if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,0xFFFFFF,"usage playerid");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,0xFFFFFF,"player is not connected");
if(sscanf(params,"udd",TargetID,Weapon,Ammo));
SendClientMessage(playerid,0xFFFFFF,"player has recieved the weapon!");
SendClientMessage(targetid,0xFFFFFF,"you have recieved a weapon!");
return 1;
}
\godmode.pwn(121) : error 036: empty statement/

Aliassassin123456
18/09/2015, 09:22 PM
CMD:agiveweapon(playerid, params[])
{
new TargetID, Weapon, Ammo;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFF, "You are not rcon admin.");
if(sscanf(params,"udd", TargetID, Weapon, Ammo)) return SendClientMessage(playerid,0xFFFFFF,"Syntax: /agiveweapon <PlayerID/PartOfName> <WeaponID> <Ammo>");
SendClientMessage(playerid,0xFFFFFF,"Player has recieved the weapon!");
SendClientMessage(targetid,0xFFFFFF,"You have recieved a weapon!");
return 1;
}


But that player will never get their weapon :| You don't give anything to them!

Andre02
18/09/2015, 09:25 PM
if/else if/else statements do not have semicolons ';' at the end!

Wrong:

if (a == b);
{
a++;
}


Correct:

if (a == b)
{
a++;
}


You should see your code again though..

saffierr
18/09/2015, 10:32 PM
ahameed, use GivePlayerWeapon();
And why are you using sscanf twice?
I don't know if that's incorrect or smth, but I've never seen it before.

Sew_Sumi
19/09/2015, 12:35 AM
ahameed, use GivePlayerWeapon();
And why are you using sscanf twice?
I don't know if that's incorrect or smth, but I've never seen it before.


if(sscanf(params,"udd",TargetID,Weapon,Ammo));


That is where the issue is... That, is an empty statement, as it doesn't have the { }, or anything done in it after the if.

if/else if/else statements do not have semicolons ';' at the end!

That is incorrect.

You can make them on one line, and they can have semicolons at the end of them, meaning it's the end of the if portion.

saffierr
19/09/2015, 01:10 AM
So, the code you need is this

CMD:agiveweapon(playerid, params[])
{
new targetid, weapon, ammo;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFF, "You are not an rcon admin!");
if(sscanf(params, "udd", targetid, weapon, ammo)) return SendClientMessage(playerid, 0xFFFFFF, "Usage: /agiveweapon [playerid]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFF, "Player is not connected!");
if(weapon < 1 || weapon > 46) return SendClientMessage(playerid, COLOR_RED, "Valid weaponids are 1 - 46"); // Because weaponid 88 is not valid...

new string[75], pname[MAX_PLAYER_NAME]; // This is to get the TARGET name (optional)
GivePlayerWeapon(targetid, weapon, ammo); // This will give the weapon to the targetid
GetPlayerName(targetid, pname, MAX_PLAYER_NAME); // This is to get the TARGETS name
format(string, sizeof string, "%s has received the weapon!", pname); // format is to define a variable, pname is the TARGETS name
SendClientMessage(playerid, 0xFFFFFF, string); // The player who committed the cmd, gets the message from the format above
SendClientMessage(targetid, 0xFFFFFF, "You have received a weapon!"); // Why didn't I use format here either? well, because there's no variable to define
return 1;
}
I hope it works, as I didn't test it.

ahameed4755
19/09/2015, 10:59 AM
So, the code you need is this

CMD:agiveweapon(playerid, params[])
{
new targetid, weapon, ammo;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFF, "You are not an rcon admin!");
if(sscanf(params, "udd", targetid, weapon, ammo)) return SendClientMessage(playerid, 0xFFFFFF, "Usage: /agiveweapon [playerid]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFF, "Player is not connected!");
if(weapon < 1 || weapon > 46) return SendClientMessage(playerid, COLOR_RED, "Valid weaponids are 1 - 46"); // Because weaponid 88 is not valid...

new string[75], pname[MAX_PLAYER_NAME]; // This is to get the TARGET name (optional)
GivePlayerWeapon(targetid, weapon, ammo); // This will give the weapon to the targetid
GetPlayerName(targetid, pname, MAX_PLAYER_NAME); // This is to get the TARGETS name
format(string, sizeof string, "%s has received the weapon!", pname); // format is to define a variable, pname is the TARGETS name
SendClientMessage(playerid, 0xFFFFFF, string); // The player who committed the cmd, gets the message from the format above
SendClientMessage(targetid, 0xFFFFFF, "You have received a weapon!"); // Why didn't I use format here either? well, because there's no variable to define
return 1;
}
I hope it works, as I didn't test it.
i use the command but it keep saying Usage [PlayerID] (this script dosent work)

Andre02
19/09/2015, 11:16 AM
That is incorrect.

You can make them on one line, and they can have semicolons at the end of them, meaning it's the end of the if portion.

Semicolons are added to 1 line if statements but after the function


if (a == b) SendClientMessage(playerid, -1, "A has the same value as B");


But not after the if statement.


if (a == b); SendClientMessage(playerid, -1, "A has the same value as B");


Which means if statements do not have semicolons but the function after it does have it.

jlalt
19/09/2015, 11:29 AM
i use the command but it keep saying Usage [PlayerID] (this script dosent work)

change :

if(sscanf(params, "udd", targetid, weapon, ammo)) return SendClientMessage(playerid, 0xFFFFFF, "Usage: /agiveweapon [playerid]");

to

if(sscanf(params, "udd", targetid, weapon, ammo)) return SendClientMessage(playerid, 0xFFFFFF, "Usage: /agiveweapon [playerid] [weaponid] [ammo]");

then /agiveweapon playerid weaponid ammo

example: /agiveweapon 0 38 5000

ahameed4755
19/09/2015, 11:42 AM
change :

if(sscanf(params, "udd", targetid, weapon, ammo)) return SendClientMessage(playerid, 0xFFFFFF, "Usage: /agiveweapon [playerid]");

to

if(sscanf(params, "udd", targetid, weapon, ammo)) return SendClientMessage(playerid, 0xFFFFFF, "Usage: /agiveweapon [playerid] [weaponid] [ammo]");

then /agiveweapon playerid weaponid ammo

example: /agiveweapon 0 38 5000

thanks! man :D i will give REP+ later bcoz i cant do it.

M0HAMMAD
19/09/2015, 12:23 PM
CMD:agiveweapon(playerid,params[])
{
new TargetID,Weapon,Ammo;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFF,"you are not rcon admin");
if(sscanf(params,"udd",targetid,Weapon,Ammo)) return SendClientMessage(playerid,0xFFFFFF,"USAGE: /AGiveWeapon (PlayerName/playerid) (Weapon ID) (Ammo)");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,0xFFFFFF,"player is not connected");
SendClientMessage(playerid,0xFFFFFF,"player has recieved the weapon!");
GivePlayerWeapon(targetid,Weapon,Ammo);
SendClientMessage(targetid,0xFFFFFF,"you have recieved a weapon!");
return 1;
}

saffierr
19/09/2015, 05:12 PM
Lol, sorry forgot to add the /agiveweapon [playerid] [AMMO]
forgot to add that, although it should be kinda obvious when you're committing that cmd IG.
Im glad that the cmd works!

Sew_Sumi
19/09/2015, 09:27 PM
Semicolons are added to 1 line if statements but after the function

Look, fact is, I was meaning about the fact that when you put them on one line, they have a semicolon at the end of the line.

I'd say unless you've been helping in the first place, avoid nitpicking on those who have been.