Give Cookie script help
#1

Код:
CMD:givecookie(playerid, params[]) // CMD for giving somebody a cookie
{
        new str[250];
        if(PlayerInfo[playerid][Level] >= 3)
        {
             if(sscanf(params, "u", playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /givecookie [Player ID]");
             if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "PlayerID is not connected.");

             PlayerInfo[playerid][Cookies] += 1;
             format(str, sizeof(str), "**Admin %s (ID:%d) has give a cookie to %s.(ID:%d) and %s cookie count is (%d)",PlayerName2(playerid),playerid, PlayerName2(playerid),playerid,PlayerName2(playerid),PlayerInfo[playerid][Cookies]);
             SendClientMessageToAll(COLOR_ORANGE, str);
             GameTextForPlayer(playerid,"~g~~h~~h~Cookie",3000,4);
             format(str, sizeof(str), "**You just gave a cookie to %s.", PlayerName2(playerid));
             SendClientMessage(playerid, COLOR_GREEN, str);

        }
        else SendClientMessage(playerid, COLOR_YELLOW, "**You're not authorized to use this command.");
        return 1;
}
help with this cookie system

when i did /givecookie ID

it only give 1 cookies

how to give /givecookie ID Amount?
Reply
#2

Try this
PHP код:
CMD:givecookie(playeridparams[]) // CMD for giving somebody a cookie
{
        new 
str[250], playeramount;
        if(
PlayerInfo[playerid][Level] >= 3)
        {
             if(
sscanf(params"ui"playeramount)) return SendClientMessage(playeridCOLOR_YELLOW"USAGE: /givecookie [Player ID] [Amount]");
             if(!
IsPlayerConnected(player)) return SendClientMessage(playeridCOLOR_YELLOW"PlayerID is not connected.");
             
PlayerInfo[player][Cookies] += amount;
             
format(strsizeof(str), "**Admin %s (ID:%d) has given %d cookie(s) to %s.(ID:%d) and %s cookie count is (%d)",PlayerName2(player),playeramountPlayerName2(player),playerid,PlayerName2(player),PlayerInfo[player][Cookies]);
             
SendClientMessageToAll(COLOR_ORANGEstr);
             
GameTextForPlayer(player,"~g~~h~~h~Cookie",3000,4);
             
format(strsizeof(str), "**You just gave %d cookie(s) to %s."amountPlayerName2(player));
             
SendClientMessage(playeridCOLOR_GREENstr);
        }
        else 
SendClientMessage(playeridCOLOR_YELLOW"**You're not authorized to use this command.");
        return 
1;

Reply
#3

Try now.
PHP код:
CMD:givecookie(playeridparams[]) // CMD for giving somebody a cookie
{
        new 
str[250], idcookies;
        if(
PlayerInfo[playerid][Level] >= 3)
        {
             if(
sscanf(params"ud"idcookies)) return SendClientMessage(playeridCOLOR_YELLOW"USAGE: /givecookie [Player ID] [COOKIES]");
             if(!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_YELLOW"PlayerID is not connected.");
             
PlayerInfo[id][Cookies] += cookies;
             
format(strsizeof(str), "**Admin %s (ID:%d) has give %d cookie to %s.(ID:%d) and %s cookie count is (%d)",PlayerName2(playerid),playeridcookiesPlayerName2(id),playerid,PlayerName2(id),PlayerInfo[id][Cookies]);
             
SendClientMessageToAll(COLOR_ORANGEstr);
             
GameTextForPlayer(id,"~g~~h~~h~Cookie",3000,4);
             
format(strsizeof(str), "**You just gave a cookie to %s."PlayerName2(id));
             
SendClientMessage(playeridCOLOR_GREENstr);
        }
        else 
SendClientMessage(playeridCOLOR_YELLOW"**You're not authorized to use this command.");
        return 
1;

Reply
#4

yeah thanks,can anyone make example

Код:
CMD:givecookie(playerid, params[]) // CMD for giving somebody a cookie
{
        new str[250], player, amount;
        if(PlayerInfo[playerid][Level] >= 3)
        {
             if(sscanf(params, "ui", player, amount)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /givecookie [Player ID] [Amount]");
             if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_YELLOW, "PlayerID is not connected.");

             PlayerInfo[player][Cookies] += amount;
             format(str, sizeof(str), "**Admin %s (ID:%d) has given %d cookie(s) to %s.(ID:%d) and %s cookie count is (%d)",PlayerName2(player),player, amount, PlayerName2(player),playerid,PlayerName2(player),PlayerInfo[player][Cookies]);
             SendClientMessageToAll(COLOR_ORANGE, str);
             GameTextForPlayer(player,"~g~~h~~h~Cookie",3000,4);
             format(str, sizeof(str), "**You just gave %d cookie(s) to %s.", amount, PlayerName2(player));
             SendClientMessage(playerid, COLOR_GREEN, str);

        }
        else SendClientMessage(playerid, COLOR_YELLOW, "**You're not authorized to use this command.");
        return 1;
}
how to giveallcookie?
Reply
#5

Add this near your stocks:
PHP код:
forward GiveAllCookies(playeridamount);
public 
GiveAllCookies(playeridamount)
{
    for(new 
i=0MAX_PLAYERSi++)
    {
         if(
IsPlayerConnected(i))
        {
            
PlayerInfo[i][Cookies] += amount;
        }
    }
      return 
1;

Then add this:
PHP код:
CMD:giveallcookie(playeridparams[]) // CMD for giving somebody a cookie
{
        new 
str[250], amount;
        if(
PlayerInfo[playerid][Level] >= 3)
        {
             if(
sscanf(params"i",amount)) return SendClientMessage(playeridCOLOR_YELLOW"USAGE: /giveallcookie [Amount]");;
             
format(strsizeof(str), "**Admin %s (ID:%d) has given %d cookie(s) to everyone!",PlayerName2(playerid), playeridamount);
             
SendClientMessageToAll(COLOR_ORANGEstr);;
             
format(strsizeof(str), "**You just gave %d cookie(s) to everyone."amount);
             
SendClientMessage(playeridCOLOR_GREENstr);
             
GiveAllCookies(playeridamount);
        }
        else 
SendClientMessage(playeridCOLOR_YELLOW"**You're not authorized to use this command.");
        return 
1;

Written from here, so I'm unsure of the errors. Just reply if there are any.
Reply
#6

Quote:
Originally Posted by aoky
Посмотреть сообщение
Add this near your stocks:
PHP код:
forward GiveAllCookies(playeridamount);
public 
GiveAllCookies(playeridamount)
{
    for(new 
i=0MAX_PLAYERSi++)
    {
         if(
IsPlayerConnected(i))
        {
            
PlayerInfo[i][Cookies] += amount;
        }
    }
      return 
1;

Then add this:
PHP код:
CMD:giveallcookie(playeridparams[]) // CMD for giving somebody a cookie
{
        new 
str[250], amount;
        if(
PlayerInfo[playerid][Level] >= 3)
        {
             if(
sscanf(params"i",amount)) return SendClientMessage(playeridCOLOR_YELLOW"USAGE: /giveallcookie [Amount]");;
             
format(strsizeof(str), "**Admin %s (ID:%d) has given %d cookie(s) to everyone!",PlayerName2(playerid), playeridamount);
             
SendClientMessageToAll(COLOR_ORANGEstr);;
             
format(strsizeof(str), "**You just gave %d cookie(s) to everyone."amount);
             
SendClientMessage(playeridCOLOR_GREENstr);
             
GiveAllCookies(playeridamount);
        }
        else 
SendClientMessage(playeridCOLOR_YELLOW"**You're not authorized to use this command.");
        return 
1;

Written from here, so I'm unsure of the errors. Just reply if there are any.
Got few error but fixed,Thanks
Reply
#7

So many copy pasta, no explanation.
He'd just keep making requests and you guys would script it for him and he wouldn't understand what the heck is in the code.

I've noticed no one fixed the "str" length from 250 to 145, because SendClientMessage just won't send beyond that.

@aoky, you have double semi colon
Код:
if(sscanf(params, "i",amount)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /giveallcookie [Amount]");;
Код:
SendClientMessageToAll(COLOR_ORANGE, str);;
Ain't sure why "GiveAllCookies" accepts playerid if its unused.
Reply
#8

Quote:
Originally Posted by Kaperstone
Посмотреть сообщение
So many copy pasta, no explanation.
He'd just keep making requests and you guys would script it for him and he wouldn't understand what the heck is in the code.

I've noticed no one fixed the "str" length from 250 to 145, because SendClientMessage just won't send beyond that.

@aoky, you have double semi colon
Код:
if(sscanf(params, "i",amount)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /giveallcookie [Amount]");;
Код:
SendClientMessageToAll(COLOR_ORANGE, str);;
Ain't sure why "GiveAllCookies" accepts playerid if its unused.
Dont be rude here,im just asking how to fix it.if u wont help then dont reply
Reply
#9

Quote:
Originally Posted by Kaperstone
Посмотреть сообщение
So many copy pasta, no explanation.
He'd just keep making requests and you guys would script it for him and he wouldn't understand what the heck is in the code.

I've noticed no one fixed the "str" length from 250 to 145, because SendClientMessage just won't send beyond that.

@aoky, you have double semi colon
Код:
if(sscanf(params, "i",amount)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /giveallcookie [Amount]");;
Код:
SendClientMessageToAll(COLOR_ORANGE, str);;
Ain't sure why "GiveAllCookies" accepts playerid if its unused.
Thanks, didn't realize. Wrote it straight from the forums, lol.
Reply
#10

Quote:
Originally Posted by aoky
Посмотреть сообщение
Thanks, didn't realize. Wrote it straight from the forums, lol.
from this ,https://sampforum.blast.hk/showthread.php?tid=510327

im just take it and edit,to improve my server script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)