13.08.2016, 13:16
(
Последний раз редактировалось Adamsy; 15.08.2016 в 05:18.
)
Hello,
I'm a beginner in scripting and I'm trying to build my own admin command to give weapon to a player.
The command would look like this: /agiveweapon [id] [weapon] [ammo]
I have searched many times how to fix my errors but some still appears and I don't know what to do to make the script understand I want to give Y weapon to X player with Z ammo.
Please tell me what's wrong and how should I do it.
> By the way SORRY i'm using strcmp my gamemode is running with it, so I have to deal with it.
The command doesn't work despite I fix the error.
Thank you very much.
I'm a beginner in scripting and I'm trying to build my own admin command to give weapon to a player.
The command would look like this: /agiveweapon [id] [weapon] [ammo]
I have searched many times how to fix my errors but some still appears and I don't know what to do to make the script understand I want to give Y weapon to X player with Z ammo.
Please tell me what's wrong and how should I do it.
> By the way SORRY i'm using strcmp my gamemode is running with it, so I have to deal with it.
pawn Код:
if(strcmp(cmd, "/agiveweapon", true) == 0)
{
tmp = strtok(cmdtext, idx);
new tmp2[256];
new tmp3[256];
tmp = strtok(cmdtext, idx);
tmp2 = strtok(cmdtext, idx);
tmp3 = strtok(cmdtext, idx);
new id;
new gun = strval(tmp2);
new ammo = strval(tmp3);
id = strval(tmp);
gun = strval(tmp2);
ammo = strval(tmp3);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[playerid][pAdmin] = dini_Int(udb_encode(sendername), "level");
PlayerInfo[giveplayerid][pAdmin] = dini_Int(udb_encode(giveplayer), "level");
}
if(logged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in!");
return 1;
}
if(PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not allowed to use that command!");
return 1;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /agiveweapon [id] [arme] [munitions]");
return 1;
}
if(!strlen(tmp2))
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /agiveweapon [id] [arme] [munitions]");
return 1;
}
if (IsPlayerConnected(giveplayerid))
{
GivePlayerWeapon(playerid, gun, ammo); // error 035: argument type mismatch (argument 2)
format(string, sizeof(string), "You have given %s a %d with %d ammo.", giveplayer, gun, ammo);
SendClientMessage(playerid, COLOR_ORANGE, string);
}
else {
format(string, sizeof(string), "ID:%d is not an active player.", id);
SendClientMessage(playerid, COLOR_BRIGHTRED, string);
return 1;
}
Thank you very much.