SA-MP Forums Archive
In need of dcmd commands [REP + + ] - 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)
+--- Thread: In need of dcmd commands [REP + + ] (/showthread.php?tid=329623)



In need of dcmd commands [REP + + ] - jotan. - 29.03.2012

Hello,I made alot of commands in dcmd,but I am having issues with making the following commands:
/setcash
/givemoney
/setname
/destroycar
/admins (My enum is PInfo)...
Can someone help me ..
I need the dcmd code for it (not zcmd,sscanf,ycmd code DCMD)



Re: In need of dcmd commands [REP + + ] - Admigo - 29.03.2012

I think its better to use an admin filterscript like ladmin or lux admin. Or search the commands in forums.


Re: In need of dcmd commands [REP + + ] - jotan. - 29.03.2012

Altought,I think its noobish to use LuxAdmin when you can learn to script and make your own one.
But I dont know just these 3 cmds,others are easy



Re: In need of dcmd commands [REP + + ] - SpiritEvil - 29.03.2012

I hope these can help you:

pawn Код:
dcmd_setcash(playerid, params[])
{
    new targetid, money;
    if(sscanf(params, "ui", targetid, money)) return SendClientMessage(playerid, 0xFF0000, "Usage: /setcash [PlayerID/Part of Name] [Amount]");
    ResetPlayerMoney(targetid);
    GivePlayerMoney(targetid, money);
    new str[128];
    format(str, sizeof(str), "You have set Player's ID %i money to %i", targetid, money);
    SendClientMessage(playerid, -1, str);
    format(str, sizeof(str), "Player ID %i has set your money to %i", playerid, money);
    SendClientMessage(targetid, -1, str);
    return 1;
}

dcmd_givemoney(playerid, params[])
{
    new targetid, money;
    if(sscanf(params, "ui", targetid, money)) return SendClientMessage(playerid, 0xFF0000, "Usage: /givemoney [PlayerID/Part of Name] [Amount]");
    if(GetPlayerMoney(playerid) < money) return SendClientMessage(playerid, 0xFF0000, "You don't have enough cash!");
    GivePlayerMoney(targetid, money);
    GivePlayerMoney(playerid, -money);
    new str[128];
    format(str, sizeof(str), "You gave $%i to Player ID %i!", money, targetid);
    SendClientMessage(playerid, -1, str);
    format(str, sizeof(str), "Player ID %i gave you $%i!", playerid, money);
    SendClientMessage(targetid, -1, str);
    return 1;
}

dcmd_setname(playerid, params[])
{
    new targetid, name[MAX_PLAYER_NAME];
    if(sscanf(params, "us[MAX_PLAYER_NAME]", targetid, name)) return SendClientMessage(playerid, 0xFF0000, "Usage: /setname [PlayerID/Part of Name] [New Name]");
    SetPlayerName(targetid, name);
    new str[128];
    format(str, sizeof(str), "You have set Player's ID %i name to %s!", targetid, name);
    SendClientMessage(playerid, -1, str);
    format(str, sizeof(str), "Player ID %i has changed your name to %s!", playerid, name);
    SendClientMessage(targetid, -1, str);
    return 1;
}

dcmd_admins(playerid, params[])
{
    #pragma unused params
    new count;
    new str[80];
    new name[MAX_PLAYER_NAME];
    SendClientMessage(playerid, -1, "~~Online Administrators~~");
    SendClientMessage(playerid, -1, " ");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PInfo[i][Admin] >= 1)
            {
                count++;
                GetPlayerName(i, name, sizeof(name));
                format(str, sizeof(str), "%s Level: %i", name, PInfo[i][Admin]);
                SendClientMessage(playerid, -1, str);
            }
        }
    }
    if(count == 0) SendClientMessage(playerid, -1, "!No Administrators online!");
    SendClientMessage(playerid, -1, "________________________________________");
    return 1;
}
Now even though you said you didn't want sscanf there are 2 reasons why I used it here:

1. I am not familiar with strtok (or whatever you are using to detect params).
2. Since you are still learning to script I strongly suggest you use sscanf because it is very simple to use (might look difficult at first but eventually you will see it's not hard at all) and it's very useful, not only for commands, but for other things as well.