SA-MP Forums Archive
givegun and slap - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: givegun and slap (/showthread.php?tid=209896)



givegun and slap - xir - 11.01.2011

I have some problems with slap.. it doesnt show the meters..

here it is
pawn Код:
dcmd_slap(playerid,params[])
{
    if(!PLVL[playerid]) return 0;
    new pid;
    if(PlayerInfo[playerid][pAdminLevel] >=1)
    {
        if(sscanf(params, "u", pid)) return SendClientMessage(playerid, Yellow, "Usage: /slap <playerid>");
        if(IsPlayerConnected(pid))
        {
        new Float:Pos[3], string[128], adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], moneys = strval(params);
        GetPlayerPos(pid,Pos[0],Pos[1],Pos[2]);
        SetPlayerPos(pid,Pos[0],Pos[1],Pos[2]+moneys);
        format(string, sizeof(string), "Admin %s has slapped %s for %d meters", adminname, paramname, moneys);
        MessageToAdmins(AdminColor, string);
        } else SendClientMessage(playerid, Red, "This player is not connected");
    } else if(PlayerInfo[playerid][pAdminLevel] == 0) return 0;
    return 1;
}
here is the givegun code, it says palyerisnot connected when i use my id also the gun name dont work

pawn Код:
dcmd_givegun(playerid, params[])
{
    if(!PLVL[playerid]) return 0;
    new id, gunid, ammo, gunname[50];
    new idx, String[128];
    String = strtok(params, idx);
    if(PlayerInfo[playerid][pAdminLevel] < 3) return 0;
    if(sscanf(params, "dsd", id, gunid, ammo)) return SendClientMessage(playerid, Yellow, "Usage: /givegun <playerid> <weaponid/name> <ammo>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, Red, "Player is not connected");
    if(gunid < 0 || gunid > 46) return SendClientMessage(playerid, Red, "Invalid weapon ID/name");
    GetWeaponModelIDFromName(String);
    if (!strlen(String))
    if (!strlen(params[idx+1]))
    GivePlayerWeapon(id, gunid, ammo);
    GetGunName(gunid, gunname, 50);
    format(String, 128, "Admin has given you a %s with %d bullets", gunname, ammo);
    SendClientMessage(id, AdminColor, String);
    return 1;
}
please help , i tried hard but still..


Re: givegun and slap - HyperZ - 11.01.2011

pawn Код:
dcmd_givegun(playerid, params[])
{
    if(!PLVL[playerid]) return 0;
    new id, gunid, ammo, gunname[32];
    new idx, String[128];
    String = strtok(params, idx);
    if(PlayerInfo[playerid][pAdminLevel] < 3) return 0;
    if(sscanf(params, "udd", id, gunid, ammo)) return SendClientMessage(playerid, Yellow, "Usage: /givegun <playerid> <weaponid/name> <ammo>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, Red, "Player is not connected");
    if(gunid < 0 || gunid > 46) return SendClientMessage(playerid, Red, "Invalid weapon ID/name");
    GetWeaponModelIDFromName(String);
    if (!strlen(String))
    if (!strlen(params[idx+1]))
    GivePlayerWeapon(id, gunid, ammo);
    GetWeaponName(gunid,gunname,32);
    format(String, 128, "Admin has given you a %s with %d bullets", gunname, ammo);
    SendClientMessage(id, AdminColor, String);
    return 1;
}



Re: givegun and slap - xir - 11.01.2011

it says Admin has given you a Desert Eagle with 0 Bullets, when I typed 50. also the gun name doesnt work


Re: givegun and slap - xir - 12.01.2011

not fixed yet please help


Re: givegun and slap - Outcast - 12.01.2011

pawn Код:
if(sscanf(params, "usd", id, gunid, ammo)) return SendClientMessage(playerid, Yellow, "Usage: /givegun <playerid> <weaponid/name> <ammo>");
Try replacing the line in your script with this one.


Re: givegun and slap - HyperZ - 12.01.2011

Quote:
Originally Posted by kreso932
Посмотреть сообщение
pawn Код:
if(sscanf(params, "usd", id, gunid, ammo)) return SendClientMessage(playerid, Yellow, "Usage: /givegun <playerid> <weaponid/name> <ammo>");
Try replacing the line in your script with this one.
It should be:
pawn Код:
if(sscanf(params, "udd", id, gunid, ammo)) return SendClientMessage(playerid, Yellow, "Usage: /givegun <playerid> <weaponid/name> <ammo>");



Re: givegun and slap - xir - 12.01.2011

The code doesnt still work , please help


Re: givegun and slap - xir - 13.01.2011

bump


Re: givegun and slap - Lorenc_ - 13.01.2011

pawn Код:
dcmd_slap(playerid,params[])
{
    if(!PLVL[playerid]) return 0;
    new pid, moneys;
    if(PlayerInfo[playerid][pAdminLevel] >=1)
    {
        if(sscanf(params, "ud", pid, moneys)) return SendClientMessage(playerid, Yellow, "Usage: /slap <playerid>");
        if(IsPlayerConnected(pid))
        {
        new Float:Pos[3], string[128], adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], moneys = strval(params);
        GetPlayerPos(pid,Pos[0],Pos[1],Pos[2]);
        SetPlayerPos(pid,Pos[0],Pos[1],Pos[2]+moneys);
        format(string, sizeof(string), "Admin %s has slapped %s for %d meters", adminname, paramname, moneys);
        MessageToAdmins(AdminColor, string);
        } else SendClientMessage(playerid, Red, "This player is not connected");
    } else if(PlayerInfo[playerid][pAdminLevel] == 0) return 0;
    return 1;
}



Re: givegun and slap - xir - 13.01.2011

hm
pawn Код:
E:\GTA San Andreas\Server\gamemodes\DMWorld.pwn(1119) : warning 219: local variable "moneys" shadows a variable at a preceding level
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
and what about the givegun cmd?