SA-MP Forums Archive
How can i make this command? - 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: How can i make this command? (/showthread.php?tid=296120)



How can i make this command? - DaRkAnGeL[NBK] - 09.11.2011

Hey,

I am fairly new to scripting and need a hand around strings.

I know about commands like OOC but not with commands for example:
pawn Код:
CMD:makeadvisor(playerid,params[])
{
    new pID;
    new sendername[MAX_PLAYER_NAME], string[36];
    if(PlayerInfo[playerid][pDonatedRank] == 5) return SendClientMessage(playerid,COLOR_WHITE,"You Cannot Use This Command");
    else if(PlayerInfo[playerid][pHelper] == 4) return SendClientMessage(playerid,COLOR_WHITE,"You Cannot Use This Command");
    else if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_WHITE,"This Player Is Not Connected");
    else
    {
        PlayerInfo[pID][pHelper] = 1;
        GetPlayerName(playerid,sendername, sizeof(sendername));
        format(string, sizeof(string),"You Have Been Set Helper By:%s",sendername);
        SendClientMessage(playerid,COLOR_WHITE,"You Have Set pID A Helper");
    }
    return 1;
}
I need to find a way for pID, Thanks in advance


Re: How can i make this command? - grand.Theft.Otto - 09.11.2011

Do you have sscanf ?


Re: How can i make this command? - DaRkAnGeL[NBK] - 09.11.2011

Yes, I have never really learnt to use it tho.


Re: How can i make this command? - grand.Theft.Otto - 09.11.2011

Learn here:

https://sampwiki.blast.hk/wiki/Fast_Commands#sscanf

Here is the finished/completed command (untested, should work):

pawn Код:
CMD:makeadvisor(playerid,params[])
{
    new pID;
   
    new sendername[24], receivername[24], string[36];
   
    GetPlayerName(playerid,sendername,24);
    GetPlayerName(pID, receivername, 24);
   
    if(sscanf(params,"u",pID)) return SendClientMessage(playerid,-1,"USAGE: /makeadvisor [playerid]");
   
    if(PlayerInfo[playerid][pDonatedRank] == 5) return SendClientMessage(playerid,COLOR_WHITE,"You Cannot Use This Command");
    if(PlayerInfo[playerid][pHelper] == 4) return SendClientMessage(playerid,COLOR_WHITE,"You Cannot Use This Command");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_WHITE,"This Player Is Not Connected");

    PlayerInfo[pID][pHelper] = 1;
   
   
    format(string,36,"You Have Been Set To Helper Status By %s (%d).",sendername, playerid);
    SendClientMessage(pID,COLOR_WHITE,string); // send the string message above to the receiver
   
    format(string,36,"You Have Set  %s (%d) To Helper Status.",receivername, pID);
    SendClientMessage(playerid,COLOR_WHITE,string); // send the string message above to the admin
   
    return 1;
}



Re: How can i make this command? - Ensconce - 10.11.2011

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
Learn here:

https://sampwiki.blast.hk/wiki/Fast_Commands#sscanf

Here is the finished/completed command (untested, should work):
Do you know what you're doing? How can you get the players name before parsing the pID through sscanf?


Re: How can i make this command? - grand.Theft.Otto - 10.11.2011

Just a mistake ...

pawn Код:
CMD:makeadvisor(playerid,params[])
{
    new pID;

    new sendername[24], receivername[24], string[36];

    if(sscanf(params,"u",pID)) return SendClientMessage(playerid,-1,"USAGE: /makeadvisor [playerid]");

    GetPlayerName(playerid,sendername,24);
    GetPlayerName(pID, receivername, 24);
   
    if(PlayerInfo[playerid][pDonatedRank] == 5) return SendClientMessage(playerid,COLOR_WHITE,"You Cannot Use This Command");
    if(PlayerInfo[playerid][pHelper] == 4) return SendClientMessage(playerid,COLOR_WHITE,"You Cannot Use This Command");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_WHITE,"This Player Is Not Connected");

    PlayerInfo[pID][pHelper] = 1;


    format(string,36,"You Have Been Set To Helper Status By %s (%d).",sendername, playerid);
    SendClientMessage(pID,COLOR_WHITE,string); // send the string message above to the receiver

    format(string,36,"You Have Set  %s (%d) To Helper Status.",receivername, pID);
    SendClientMessage(playerid,COLOR_WHITE,string); // send the string message above to the admin

    return 1;
}



Re: How can i make this command? - Ensconce - 10.11.2011

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
Just a mistake ...

pawn Код:
code
You need more cells in the string variable, as "You Have Been Set To Helper Status By " is 38 characters already. Therefore the output will not be formatted properly. I suggest you make it at least 70 cells.


Re: How can i make this command? - DaRkAnGeL[NBK] - 10.11.2011

Guys my server is complete thanks for the help


Re: How can i make this command? - grand.Theft.Otto - 10.11.2011

128 is the recommended cell/character amount.

You can change 36 to 128.