Cookies?
#1

hello!

I am just wondering on how I can make my own cookie system? Cookies is ment to be some kind of a treasure when u win in DM's, and should be used to buy special things.

I Dont know at all where to start, so I need someone to tell me what I need to do.

Thanks!

airplanesimen.
Reply
#2

Use variables.. Create global variable Cookies for all players
pawn Код:
new Cookies[MAX_PLAYERS];
then if you like to add player some cookies, use:
pawn Код:
Cookies[playerid] += 1;
there is more things, but its only simple variable(s)... Look for some tutorials on forum or wiki
Reply
#3

Thanks alot! Helped alot; ) the difficult part is to save cookies per player until next time they connect XD
Reply
#4

Can someone provide an example to me how i can write this "cookie information" to a file, ini file, so the player can connect again with the same amount of cookies?

Thanks.
Reply
#5

Sure for Example if you are admin you have to use this to give cookie
Код:
CMD:givecookie(playerid, params[])
{
        if(pInfo[playerid][pLevel] >= 1) // Change this to your system stuff
	    {
        new pid;
        new str[250];
        if(sscanf(params, "u", pid)) return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "USAGE: /givecookie [Player ID]");
        if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "PlayerID is not connected.");
        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
        PlayerPlaySound(pid, 1057, 0.0, 0.0, 0.0);
        pPinfo[pid][Cookies] += 1;
        format(str, sizeof(str), "-Server- Admin %s (ID:%d) Gave %s(ID: %d) A Cookie [Total: %d] ",GetName(playerid),playerid,GetName(pid),pid,pPinfo[pid][Cookies]); //Change the text if you want
        SendClientMessageToAll(COLOR_GREEN, str);
        GameTextForPlayer(pid,"~g~~h~~h~Cookie!",3000,4); // Change this GameText if you want
        */new string[134],cookie[100];
        format(cookie, sizeof(cookie), "02 03* 7,15 Admin %s (ID:%d) Gave %s(ID: %d) A Cookie [Total: %d] .", GetName(playerid),playerid,GetName(pid),pid,pPinfo[pid][Cookies]);
        IRC_GroupSay(groupID, IRC_CHANNEL, cookie);/* // Use this if you have a IRC System inside the Admin system
		return 1;
		}
        else return ShowMessage(playerid,red,1);
}
Then you have to create folder named " Cookies " in script files
to make the cookies being saved:
Код:
enum Ppinfo
{
    Cookies
}
Код:
OnPlayerDisconnect
INI_WriteInt(file,"Cookies",pPinfo[playerid][Cookies]);
Код:
#define COLOR_MESSAGE_YELLOW            0xFFDD00AA
#define UserPath "cookies/%s.ini"
stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath,name);
    return str;
}
+Rep if i helped you !
Reply
#6

Quote:
Originally Posted by Ultraz
Посмотреть сообщение
Sure for Example if you are admin you have to use this to give cookie
Код:
CMD:givecookie(playerid, params[])
{
        if(pInfo[playerid][pLevel] >= 1) // Change this to your system stuff
	    {
        new pid;
        new str[250];
        if(sscanf(params, "u", pid)) return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "USAGE: /givecookie [Player ID]");
        if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "PlayerID is not connected.");
        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
        PlayerPlaySound(pid, 1057, 0.0, 0.0, 0.0);
        pPinfo[pid][Cookies] += 1;
        format(str, sizeof(str), "-Server- Admin %s (ID:%d) Gave %s(ID: %d) A Cookie [Total: %d] ",GetName(playerid),playerid,GetName(pid),pid,pPinfo[pid][Cookies]); //Change the text if you want
        SendClientMessageToAll(COLOR_GREEN, str);
        GameTextForPlayer(pid,"~g~~h~~h~Cookie!",3000,4); // Change this GameText if you want
        */new string[134],cookie[100];
        format(cookie, sizeof(cookie), "02 03* 7,15 Admin %s (ID:%d) Gave %s(ID: %d) A Cookie [Total: %d] .", GetName(playerid),playerid,GetName(pid),pid,pPinfo[pid][Cookies]);
        IRC_GroupSay(groupID, IRC_CHANNEL, cookie);/* // Use this if you have a IRC System inside the Admin system
		return 1;
		}
        else return ShowMessage(playerid,red,1);
}
Then you have to create folder named " Cookies " in script files
to make the cookies being saved:
Код:
enum Ppinfo
{
    Cookies
}
Код:
OnPlayerDisconnect
INI_WriteInt(file,"Cookies",pPinfo[playerid][Cookies]);
Код:
#define COLOR_MESSAGE_YELLOW            0xFFDD00AA
#define UserPath "cookies/%s.ini"
stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath,name);
    return str;
}
+Rep if i helped you !
LMAO stop saying rep if i helped you at every topic you reply
Reply
#7

Quote:
Originally Posted by Ultraz
Посмотреть сообщение
Sure for Example if you are admin you have to use this to give cookie
Код:
CMD:givecookie(playerid, params[])
{
        if(pInfo[playerid][pLevel] >= 1) // Change this to your system stuff
	    {
        new pid;
        new str[250];
        if(sscanf(params, "u", pid)) return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "USAGE: /givecookie [Player ID]");
        if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "PlayerID is not connected.");
        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
        PlayerPlaySound(pid, 1057, 0.0, 0.0, 0.0);
        pPinfo[pid][Cookies] += 1;
        format(str, sizeof(str), "-Server- Admin %s (ID:%d) Gave %s(ID: %d) A Cookie [Total: %d] ",GetName(playerid),playerid,GetName(pid),pid,pPinfo[pid][Cookies]); //Change the text if you want
        SendClientMessageToAll(COLOR_GREEN, str);
        GameTextForPlayer(pid,"~g~~h~~h~Cookie!",3000,4); // Change this GameText if you want
        */new string[134],cookie[100];
        format(cookie, sizeof(cookie), "02 03* 7,15 Admin %s (ID:%d) Gave %s(ID: %d) A Cookie [Total: %d] .", GetName(playerid),playerid,GetName(pid),pid,pPinfo[pid][Cookies]);
        IRC_GroupSay(groupID, IRC_CHANNEL, cookie);/* // Use this if you have a IRC System inside the Admin system
		return 1;
		}
        else return ShowMessage(playerid,red,1);
}
Then you have to create folder named " Cookies " in script files
to make the cookies being saved:
Код:
enum Ppinfo
{
    Cookies
}
Код:
OnPlayerDisconnect
INI_WriteInt(file,"Cookies",pPinfo[playerid][Cookies]);
Код:
#define COLOR_MESSAGE_YELLOW            0xFFDD00AA
#define UserPath "cookies/%s.ini"
stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath,name);
    return str;
}
+Rep if i helped you !
Thanks for bumping a 3 year old topic, which I haven't bumped myself because i found out of it after a while.

However, if you were helping a newbie, I would suggest you to use the stock functions to avoid confusing people what to do, and stick to the problem only
Reply
#8

Quote:
Originally Posted by denNorske
Посмотреть сообщение
Thanks for bumping a 3 year old topic, which I haven't bumped myself because i found out of it after a while.

However, if you were helping a newbie, I would suggest you to use the stock functions to avoid confusing people what to do, and stick to the problem only
LMAO i didn't even notice it's 3 y/o
Reply
#9

Sorry , I dunno it is old thread , thnx for your advise .
Reply
#10

Quote:
Originally Posted by Ultraz
Посмотреть сообщение
Sorry , I dunno it is old thread , thnx for your advise .
You didn't the thread was old? You must've searched for it seeing as it's from 2012.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)