07.06.2012, 22:31
Hi there.
I have a givegun command for my server and everything works fine i guess. but there is one thing. When i use that command it gives a weapon to other person but shows "Server: Unknown command'
How to fix that small thing? There is the code.
I have a givegun command for my server and everything works fine i guess. but there is one thing. When i use that command it gives a weapon to other person but shows "Server: Unknown command'
How to fix that small thing? There is the code.
pawn Code:
if(strcmp(cmd, "/givegun", true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "{8FE11F}** {C8D1CC}/givegun [id] [daudzums]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
if (giveplayerid == playerid) return SendClientMessage(playerid, COLOR_GREY,"{ff0000}** {C8D1CC}Tu nevari dot ieroci pats sev!");
if(giveplayerid != INVALID_PLAYER_ID)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(giveplayerid,x,y,z);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
{
SendClientMessage(playerid, COLOR_GREY, "{ff0000}** {C8D1CC}Spēlētājs nav tuvumā!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "{8FE11F}** {C8D1CC}/givegun [id] [daudzums]");
return 1;
}
new sammo = GetPlayerAmmo(playerid);
new weapon = GetPlayerWeapon(playerid);
new ammo = strval(tmp);
if(ammo > sammo)
{
SendClientMessage(playerid, COLOR_GREY, "{ff0000}** {C8D1CC}Jums nav tik daudz lodes.");
return 1;
}
GivePlayerWeapon(giveplayerid, weapon, ammo);
GivePlayerWeapon(playerid, weapon, -ammo);
format(string, sizeof(string), "* %s tev iedeva ieroci ar %d lodēm.", sendername, ammo);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* Tu iedevi speletajam %s ieroci ar %d lodēm.", giveplayer, ammo);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "{ff0000}** {C8D1CC}Spēlētājs nav pieslēdzies!");
return 1;
}
}