[FilterScript] RCookies - The first reward system that fits all the kinds of servers
#1

RCookies V1.0 by R4nd4ll


Hello there !

This is my second FS. I created this while trying to learn PAWN.
This is considered as my first FS tho, Because the first one was trash.

It's a simple cookies reward system to reward the dedicated players in your server for any reason.
Yeah so, It's pretty simple.


Ranks and Commands


Normal Player : /usecookies - /cookies
Junior Rewarder : /givecookie - /giveallcookie - /rewarderhelp
General Rewarder : /setcookies
Head Rewarder : /makerewarder

P.S : /cookies is to check how many cookies you've got.
Includes :


sscanf2 - By Y_Less & Emmet
foreach - Y_Less
ZMCD - Zeex
Yini - Y_Less
Special thanks to :


Y_Less - who made our scripting life easier
Emmet - The 2nd legend after Y_Less
Arbico
Ritzy
Zeex
Sorry if i forgot anyone...
Screenshots :
I'll add more later, I am busy with something atm

Download :
Reply
#2

Thank you for the credits! And Kudos to you for your approach of teaching yourself scripting
Reply
#3

Quote:
Originally Posted by Ritzy
View Post
Thank you for the credits! And Kudos to you for your approach of teaching yourself scripting
Dont thank me, You taught me how to use formats and SCMs.

Thank you my friend, I promise that i will be working on something better and have more knowledge in PAWN.
Reply
#4

looks pretty cool goodjob.
Reply
#5

PHP Code:
#define DIALOG_COOKIE   1 
Dialogs starts their ID at (0) just like any other ID formatted function.

PHP Code:
enum CookieInfo
{
    
Cookies,
    
RLevel
}
new 
cInfo[MAX_PLAYERS][CookieInfo]; 
Seems useless to me to use an enum for 2 variables, could've just done this.
PHP Code:
new cInfo[MAX_PLAYERS][2]; 
PHP Code:
stock Path(playerid)
{
    new 
str[128],name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,name,sizeof(name));
    
format(str,sizeof(str),UserPath,name);
    return 
str;

Why is this a stock, better yet, why is it a function?

PHP Code:
stock GetName(playerid)
{
    new 
name[24];
    
GetPlayerName(playerid,name,24);
    return 
name;

Again, why is it a stock? Plus, this and the other function above serves no intentional usage, pure lazyness.

PHP Code:
stock NotAuthorized(playerid)
{
SendClientMessage(playeridCOLOR_GREY"You don't have permission to use this command.");

This makes no sense to be a stock, or even a function.. Like why..

PHP Code:
stock PlayerName(playerid)
{
new 
pname[MAX_PLAYER_NAME];
GetPlayerName(playeridpnameMAX_PLAYER_NAME);
return 
pname;

You already declared one "GetPlayerName" function, clearly you've copy pasted this.

PHP Code:
SetPlayerHealth(playerid99.00);
and
SetPlayerArmour(playerid99.00); 
Why 99.0 and not 100.0?

PHP Code:
GivePlayerWeapon(playerid34100);
                            
GivePlayerWeapon(playerid29300);
                            
GivePlayerWeapon(playerid31200); 
You should learn to use MACROs from start, I.E: WEAPON_BRASSKNUCKLE

PHP Code:
new Float:XFloat:YFloat:Z;
                            
GetPlayerPos(playeridXYZ);
                            
CreateVehicle(522X+4YZ82.2873, -1, -160); 
You're setting the vehicle's position 4 units->east. This makes the vehicle in risk of being spawned inside of an object.
You're also setting the angle to 82.2-.. Why not use GetPlayerFacing Angle?
Also, last but not least, you're not checking whether the player is in a virtual world, interior or w/e.
(look up PutPlayerInVehicle as well)

PHP Code:
CMD:rewarderhelp(playerid,params[])
{
    if(
cInfo[playerid][RLevel] == 1)
    {
        
SendClientMessage(playeridCOLOR_LB,"Junior Rewarder : /givecookie - /givecookieall - /rewardrehelp");
    }
    if(
cInfo[playerid][RLevel] == 2)
    {
        
SendClientMessage(playeridCOLOR_LB,"Junior Rewarder : /givecookie - /giveallcookie - /rewardrehelp");
        
SendClientMessage(playeridCOLOR_LB,"General Rewarder : /setcookies");
    }
    if(
cInfo[playerid][RLevel] == || (IsPlayerAdmin(playerid)))
    {
        
SendClientMessage(playeridCOLOR_LB,"Junior Rewarder : /givecookie - /givecookieall - /rewardrehelp");
        
SendClientMessage(playeridCOLOR_LB,"General Rewarder : /setcookies");
        
SendClientMessage(playeridCOLOR_LB,"Head Rewarder : /makerewarder");
    }
    else
    {
        
NotAuthorized(playerid);
    }
    return 
1;

Look up switch() for better optimization and stylish design.

PHP Code:
if(level || level 0
Can be replaced with
PHP Code:
if(level 3
PHP Code:
if (level == 0) return SendClientMessage(targetidCOLOR_LB,"You have beeen fired from your position as a rewarder");
        if (
level == 1) return SendClientMessage(targetidCOLOR_LB,"You have been set as a Junior Rewarder");
        if (
level == 2) return SendClientMessage(targetidCOLOR_LB,"You have been set as a General Rewarder");
        if (
level == 3) return SendClientMessage(targetidCOLOR_LB,"You have been set as a Head Rewarder"); 
Again, use switch()





Code is not well-looking at all, try fixing it and making the filterscript useful(being the keyword here) and release it again.
Reply
#6

Well my friend, I am in the learning phase.

Anyway thanks for your help. +Rep
Reply
#7

Quote:
Originally Posted by Meller
View Post
PHP Code:
#define DIALOG_COOKIE   1 
Dialogs starts their ID at (0) just like any other ID formatted function.

PHP Code:
enum CookieInfo
{
    
Cookies,
    
RLevel
}
new 
cInfo[MAX_PLAYERS][CookieInfo]; 
Seems useless to me to use an enum for 2 variables, could've just done this.
PHP Code:
new cInfo[MAX_PLAYERS][2]; 
PHP Code:
stock Path(playerid)
{
    new 
str[128],name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,name,sizeof(name));
    
format(str,sizeof(str),UserPath,name);
    return 
str;

Why is this a stock, better yet, why is it a function?

PHP Code:
stock GetName(playerid)
{
    new 
name[24];
    
GetPlayerName(playerid,name,24);
    return 
name;

Again, why is it a stock? Plus, this and the other function above serves no intentional usage, pure lazyness.

PHP Code:
stock NotAuthorized(playerid)
{
SendClientMessage(playeridCOLOR_GREY"You don't have permission to use this command.");

This makes no sense to be a stock, or even a function.. Like why..

PHP Code:
stock PlayerName(playerid)
{
new 
pname[MAX_PLAYER_NAME];
GetPlayerName(playeridpnameMAX_PLAYER_NAME);
return 
pname;

You already declared one "GetPlayerName" function, clearly you've copy pasted this.

PHP Code:
SetPlayerHealth(playerid99.00);
and
SetPlayerArmour(playerid99.00); 
Why 99.0 and not 100.0?

PHP Code:
GivePlayerWeapon(playerid34100);
                            
GivePlayerWeapon(playerid29300);
                            
GivePlayerWeapon(playerid31200); 
You should learn to use MACROs from start, I.E: WEAPON_BRASSKNUCKLE

PHP Code:
new Float:XFloat:YFloat:Z;
                            
GetPlayerPos(playeridXYZ);
                            
CreateVehicle(522X+4YZ82.2873, -1, -160); 
You're setting the vehicle's position 4 units->east. This makes the vehicle in risk of being spawned inside of an object.
You're also setting the angle to 82.2-.. Why not use GetPlayerFacing Angle?
Also, last but not least, you're not checking whether the player is in a virtual world, interior or w/e.
(look up PutPlayerInVehicle as well)

PHP Code:
CMD:rewarderhelp(playerid,params[])
{
    if(
cInfo[playerid][RLevel] == 1)
    {
        
SendClientMessage(playeridCOLOR_LB,"Junior Rewarder : /givecookie - /givecookieall - /rewardrehelp");
    }
    if(
cInfo[playerid][RLevel] == 2)
    {
        
SendClientMessage(playeridCOLOR_LB,"Junior Rewarder : /givecookie - /giveallcookie - /rewardrehelp");
        
SendClientMessage(playeridCOLOR_LB,"General Rewarder : /setcookies");
    }
    if(
cInfo[playerid][RLevel] == || (IsPlayerAdmin(playerid)))
    {
        
SendClientMessage(playeridCOLOR_LB,"Junior Rewarder : /givecookie - /givecookieall - /rewardrehelp");
        
SendClientMessage(playeridCOLOR_LB,"General Rewarder : /setcookies");
        
SendClientMessage(playeridCOLOR_LB,"Head Rewarder : /makerewarder");
    }
    else
    {
        
NotAuthorized(playerid);
    }
    return 
1;

Look up switch() for better optimization and stylish design.

PHP Code:
if(level || level 0
Can be replaced with
PHP Code:
if(level 3
PHP Code:
if (level == 0) return SendClientMessage(targetidCOLOR_LB,"You have beeen fired from your position as a rewarder");
        if (
level == 1) return SendClientMessage(targetidCOLOR_LB,"You have been set as a Junior Rewarder");
        if (
level == 2) return SendClientMessage(targetidCOLOR_LB,"You have been set as a General Rewarder");
        if (
level == 3) return SendClientMessage(targetidCOLOR_LB,"You have been set as a Head Rewarder"); 
Again, use switch()





Code is not well-looking at all, try fixing it and making the filterscript useful(being the keyword here) and release it again.
1. Enum gives the liberty to name variables, why not use enum? If the script were to grow later, it will be extremely confusing with the way you mentioned.
2. NotAuthorized stock can be useful if the filterscript is to grow more, better than writing SCM over and over, plus what's wrong with a stock?
(I personally use the same approach while writing gamemodes.)

3.
Code:
if(0 < level > 3)
Readibilty of the code is preferred over anything, especially since this is a script by rookie for rookies.
Same goes for switch and if-else issue that you mentioned. Switch only impoves the script by few nanoseconds, but like I said, readibility over anything.

I'm not trying to limit R4nd4ll's knowledge or trying to make an arguement over here.
Reply
#8

https://sampforum.blast.hk/showthread.php?tid=570635
Reply
#9

PHP Code:
stock NotAuthorized(playerid)
{
SendClientMessage(playeridCOLOR_GREY"You don't have permission to use this command.");

You are just lazy.
stock is not needed in this case. It's a simple filterscript, nothing advance, no confusing stuff.
Reply
#10

Quote:
Originally Posted by Meller
View Post
idk i told this before....

that thread is complete bullshit..using stock or not using it doesn't affect the binary.

Quote:
Originally Posted by Meller
View Post
PHP Code:
#define DIALOG_COOKIE   1 
Dialogs starts their ID at (0) just like any other ID formatted function.

.................................................. ....
None of that suggestions is valid or gonna make any change rather than coding style.


even though @Op's style of programming is not uniform and has unnecessary splattered codes as you mentioned which proves copy pasting..1 star
Reply
#11

Quote:
Originally Posted by GhostHacker9
View Post
idk i told this before....

that thread is complete bullshit..using stock or not using it doesn't affect the binary.



None of that suggestions is valid or gonna make any change rather than coding style.


even though @Op's style of programming is not uniform and has unnecessary splattered codes as you mentioned which proves copy pasting..1 star
You just made you point and then you proved yourself wrong.
--
"None of that suggestions is valid or gonna make any change rather than coding style."

@Op's style of programming is not uniform and has unnecessary splattered codes as you mentioned which proves copy pasting
Reply
#12

Quote:
Originally Posted by rfr
View Post
You just made you point and then you proved yourself wrong.
--
"None of that suggestions is valid or gonna make any change rather than coding style."

@Op's style of programming is not uniform and has unnecessary splattered codes as you mentioned which proves copy pasting
How the hell he proved himself wrong? He meant the "suggestions" are invalid and even if those are wrong what meller about copy pasting is true..
Reply
#13

Some of you don't know shit about coding. There's nothing wrong with putting a single message in a function because that function will be easier to escalate or maintain if the project grows larger. If he wants to change the message for the error, he just has to edit that single function and not all the SendClientMessages scattered all over the script. What if he wants to add a special function to the error, like play a sound? He only has to edit that only one function instead of adding a bunch of PlaySound functions. Some of the other criticism is just based on your personal preferences (yes there is no difference between using "if else if" to "switch foo case" beyond what you prefer to read). Give this man a break, this code isn't that bad at all!
Reply
#14

Nice, keep it up
Reply
#15

Nice one! rep +
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)