Problem with strcmp
#7

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
No problem
And I have a little tip to make the script different. Don't use:
Код:
if (something is true )
   DO SOMETHING
but
Код:
if (this is not true) return //something
Ehm here's a little example:

What you do:
pawn Код:
if(IsPlayerAdmin(playerid))
{
    SetPlayerMoney(playerid, 100);
    printf("Player ID %d is an admin and received 100 dollar!", playerid);
}
What I mean:
pawn Код:
if(!IsPlayerAdmin(playerid)) return 0; //Stop.. xD
SetPlayerMoney(playerid, 100);
printf("Player ID %d is an admin and received 100 dollar!", playerid);
So your script will look like this:

pawn Код:
COMMAND:takejob(playerid, params[])
{
    if(player[playerid][ajob] != 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR » You already have a job, use /quitjob first"); //You've done good here
    new job, accept[64], jobstring[128];
    //This is removed (sscanf)
    printf("Parameters: %s", accept);
    if(!IsPlayerInRangeOfPoint(playerid, 10.0, 2512.4465,-1473.9086,24.8523)) return false;
    if(sscanf(params, "s[63]", accept)) return SendClientMessage(playerid, COLOR_WHITE, "Are you sure you want the job? Type /takejob confirm");
    job = 1;
    player[playerid][ajob] = job;
    SavePlayerData(playerid, "ajob", player[playerid][ajob], 2);
    format(jobstring, sizeof(jobstring), "NOTE » You are now a %s type /help for more information and perks.", ReturnJobName(job));
    SendClientMessage(playerid, COLOR_YELLOW, jobstring);
    return 1;

}
It saves a bit diskspace. But with every function/command, it CAN save alot of diskspace!
But it's just an tip. Use what you like
Problem is that it's several jobs and I find it more clean to do it that way.
Reply


Messages In This Thread
Problem with strcmp - by hanzen - 04.01.2011, 17:31
Re: Problem with strcmp - by Kwarde - 04.01.2011, 17:37
Re: Problem with strcmp - by hanzen - 04.01.2011, 17:49
Re: Problem with strcmp - by Kwarde - 04.01.2011, 17:52
Re: Problem with strcmp - by hanzen - 04.01.2011, 17:54
Re: Problem with strcmp - by Kwarde - 04.01.2011, 18:00
Re: Problem with strcmp - by hanzen - 04.01.2011, 18:03
Re: Problem with strcmp - by Kwarde - 04.01.2011, 18:06

Forum Jump:


Users browsing this thread: 2 Guest(s)