help me!
#1

Код:
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/
Reply
#2

PHP код:
CMD:agiveweapon(playeridparams[])
{
    new 
TargetIDWeaponAmmo;
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFFFFFF"You are not rcon admin.");
    if(
sscanf(params,"udd"TargetIDWeaponAmmo)) 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!
Reply
#3

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

Wrong:
pawn Код:
if (a == b);
{
    a++;
}
Correct:
pawn Код:
if (a == b)
{
    a++;
}
You should see your code again though..
Reply
#4

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.
Reply
#5

Quote:
Originally Posted by saffierr
Посмотреть сообщение
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.
PHP код:
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.

Quote:
Originally Posted by Andre02
Посмотреть сообщение
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.
Reply
#6

So, the code you need is this

PHP код:
CMD:agiveweapon(playeridparams[])
{
    new 
targetidweaponammo;
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFFFFFF"You are not an rcon admin!");
    if(
sscanf(params"udd"targetidweaponammo)) return SendClientMessage(playerid0xFFFFFF"Usage: /agiveweapon [playerid]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid0xFFFFFF"Player is not connected!");
    if(
weapon || weapon 46) return SendClientMessage(playeridCOLOR_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(targetidweaponammo); // This will give the weapon to the targetid
    
GetPlayerName(targetidpnameMAX_PLAYER_NAME); // This is to get the TARGETS name
    
format(stringsizeof string"%s has received the weapon!"pname); // format is to define a variable,  pname is the TARGETS name
    
SendClientMessage(playerid0xFFFFFFstring); // The player who committed the cmd, gets the message from the format above
    
SendClientMessage(targetid0xFFFFFF"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.
Reply
#7

Quote:
Originally Posted by saffierr
Посмотреть сообщение
So, the code you need is this

PHP код:
CMD:agiveweapon(playeridparams[])
{
    new 
targetidweaponammo;
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFFFFFF"You are not an rcon admin!");
    if(
sscanf(params"udd"targetidweaponammo)) return SendClientMessage(playerid0xFFFFFF"Usage: /agiveweapon [playerid]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid0xFFFFFF"Player is not connected!");
    if(
weapon || weapon 46) return SendClientMessage(playeridCOLOR_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(targetidweaponammo); // This will give the weapon to the targetid
    
GetPlayerName(targetidpnameMAX_PLAYER_NAME); // This is to get the TARGETS name
    
format(stringsizeof string"%s has received the weapon!"pname); // format is to define a variable,  pname is the TARGETS name
    
SendClientMessage(playerid0xFFFFFFstring); // The player who committed the cmd, gets the message from the format above
    
SendClientMessage(targetid0xFFFFFF"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)
Reply
#8

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
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

pawn Код:
if (a == b) SendClientMessage(playerid, -1, "A has the same value as B");
But not after the if statement.

pawn Код:
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.
Reply
#9

Quote:
Originally Posted by ahameed4755
Посмотреть сообщение
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
PHP код:
if(sscanf(params"udd"targetidweaponammo)) return SendClientMessage(playerid0xFFFFFF"Usage: /agiveweapon [playerid] [weaponid] [ammo]"); 
then /agiveweapon playerid weaponid ammo

example: /agiveweapon 0 38 5000
Reply
#10

Quote:
Originally Posted by Andre02
Посмотреть сообщение
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)