Signcheck Problem.
#1

Hey, it's me "Again", :P, I'm having a problem with my /signcheck [number]. So at payday you get a textdraw at the side saying "Payday: [Number] and it shows a random number, so I goto the post office and /signcheck that number and of course I get the check, but then if I enter a different number then what it shows on the Textdraw at the side it still gives me the check. Here's my code.

Код:
CMD:signcheck(playerid, params[])
{
    new randcn = 10000 + random(999999);
    if(sscanf(params, "d", randcn)) return SendClientMessage(playerid, -1, "USAGE: /signcheck [number]");
    {
	if(CheckReady[playerid] == 1)
	{
 	    if(IsPlayerInRangeOfPoint(playerid, 4.0, 915.9413,2370.7383,246.4621))
   	    {
                 PayDayCheck(playerid);
       		 CheckReady[playerid] = 0;
	    }
	    else return SendClientMessage(playerid, COLOR_WHITE, "You have entered an invalid check number!");
        }
	else return SendClientMessage(playerid, COLOR_WHITE, "Your check isn't ready to be collected.");
    }
    return 1;
}
Код:
public ClockUpdate()
{
	for(new x = 0; x < MAX_PLAYERS; x++)
	{
		if(Logged[x] == 1)
		{
			new string[12];
			new string1[12];
   			new randcn = 10000 + random(999999);
			Second += 1;
			format(string, sizeof(string), "%i:%i:%i", Hour, Minute, Second);
			if(Second == 60)
			{
			    if(Minute == 59)
				{
				    for(new i = 0; i < MAX_PLAYERS; i++)
				    {
				        if(IsPlayerConnected(i))
				        {
				    		SendClientMessage(i, COLOR_ORANGE, "Payday! Your check has arrived, head to the post office in Fort Carson!.");
						    CheckReady[i] = 1;
						    format(string1,sizeof (string1),"Payday: %d", randcn);
							TextDrawSetString(Payday, string1);
							TextDrawShowForAll(Payday);
						}
					}
				    if(Hour == 23)
				    {
				    	Hour = 0;
				    	Minute = 0;
				    	Second = 0;
					}
					else
					{
					    Hour ++;
						Minute = 0;
						Second = 0;
					}
				}
				else
				{
				    Minute ++;
			    	Second = 0;
		  		}
			}
			format(string,sizeof (string),"%02i:%02i:%02i", Hour, Minute, Second);
			TextDrawSetString(Clock, string);
			SetWorldTime(Hour);
		}
	}
	return 1;
}
Reply
#2

pawn Код:
// Somewhere at the top of your gamemode
    new randcn;
    // CMD
    CMD:signcheck(playerid, params[])
    {
        new inputnum;
        if(!sscanf(params, "d", inputnum))
        {
            if(inputnum == randcn)
            {
                if(CheckReady[playerid] == 1)
                {
                    if(IsPlayerInRangeOfPoint(playerid, 4.0, 915.9413,2370.7383,246.4621))
                    {
                        PayDayCheck(playerid);
                        CheckReady[playerid] = 0;
                    } else return SendClientMessage(playerid, COLOR_WHITE, "You are not at the location to get your payday.");
                } else return SendClientMessage(playerid, COLOR_WHITE, "Your check isn't ready to be collected.");
            } else return SendClientMessage(playerid, COLOR_WHITE, "You inserted the wrong number.");
        } else return SendClientMessage(playerid, -1, "USAGE: /signcheck [number]");
        return 1;
    }
Then replace ClockUpdate()
with:
pawn Код:
public ClockUpdate()
{
    for(new x = 0; x < MAX_PLAYERS; x++)
    {
        if(Logged[x] == 1)
        {
            new string[12];
            new string1[12];
            Second += 1;
            format(string, sizeof(string), "%i:%i:%i", Hour, Minute, Second);
            if(Second == 60)
            {
                if(Minute == 59)
                {
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    {
                        if(IsPlayerConnected(i))
                        {
                            randcn = 10000 + random(999999);
                            SendClientMessage(i, COLOR_ORANGE, "Payday! Your check has arrived, head to the post office in Fort Carson!.");
                            CheckReady[i] = 1;
                            format(string1,sizeof (string1),"Payday: %d", randcn);
                            TextDrawSetString(Payday, string1);
                            TextDrawShowForAll(Payday);
                        }
                    }
                    if(Hour == 23)
                    {
                        Hour = 0;
                        Minute = 0;
                        Second = 0;
                    }
                    else
                    {
                        Hour ++;
                        Minute = 0;
                        Second = 0;
                    }
                }
                else
                {
                    Minute ++;
                    Second = 0;
                }
            }
            format(string,sizeof (string),"%02i:%02i:%02i", Hour, Minute, Second);
            TextDrawSetString(Clock, string);
            SetWorldTime(Hour);
        }
    }
    return 1;
}
The only problem is, it will only work with one player.
If you wan't it to work with more players you should edit,
randcn to a player variable, and also edit the textdraw to a player textdraw.
Reply
#3

Quote:
Originally Posted by Roel
Посмотреть сообщение
pawn Код:
// Somewhere at the top of your gamemode
    new randcn;
    // CMD
    CMD:signcheck(playerid, params[])
    {
        new inputnum;
        if(!sscanf(params, "d", inputnum))
        {
            if(inputnum == randcn)
            {
                if(CheckReady[playerid] == 1)
                {
                    if(IsPlayerInRangeOfPoint(playerid, 4.0, 915.9413,2370.7383,246.4621))
                    {
                        PayDayCheck(playerid);
                        CheckReady[playerid] = 0;
                    } else return SendClientMessage(playerid, COLOR_WHITE, "You are not at the location to get your payday.");
                } else return SendClientMessage(playerid, COLOR_WHITE, "Your check isn't ready to be collected.");
            } else return SendClientMessage(playerid, COLOR_WHITE, "You inserted the wrong number.");
        } else return SendClientMessage(playerid, -1, "USAGE: /signcheck [number]");
        return 1;
    }
Then replace ClockUpdate()
with:
pawn Код:
public ClockUpdate()
{
    for(new x = 0; x < MAX_PLAYERS; x++)
    {
        if(Logged[x] == 1)
        {
            new string[12];
            new string1[12];
            Second += 1;
            format(string, sizeof(string), "%i:%i:%i", Hour, Minute, Second);
            if(Second == 60)
            {
                if(Minute == 59)
                {
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    {
                        if(IsPlayerConnected(i))
                        {
                            randcn = 10000 + random(999999);
                            SendClientMessage(i, COLOR_ORANGE, "Payday! Your check has arrived, head to the post office in Fort Carson!.");
                            CheckReady[i] = 1;
                            format(string1,sizeof (string1),"Payday: %d", randcn);
                            TextDrawSetString(Payday, string1);
                            TextDrawShowForAll(Payday);
                        }
                    }
                    if(Hour == 23)
                    {
                        Hour = 0;
                        Minute = 0;
                        Second = 0;
                    }
                    else
                    {
                        Hour ++;
                        Minute = 0;
                        Second = 0;
                    }
                }
                else
                {
                    Minute ++;
                    Second = 0;
                }
            }
            format(string,sizeof (string),"%02i:%02i:%02i", Hour, Minute, Second);
            TextDrawSetString(Clock, string);
            SetWorldTime(Hour);
        }
    }
    return 1;
}
The only problem is, it will only work with one player.
If you wan't it to work with more players you should edit,
randcn to a player variable, and also edit the textdraw to a player textdraw.
Thanks very much, bud.

EDIT: Just tested, it said I inserted the wrong number, I inserted the one that came up at the side and it said it was wrong.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)