COMMAND:takejob(playerid, params[])
{
if(player[playerid][ajob] != 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR » You already have a job, use /quitjob first");
new job, accept[64], jobstring[128];
sscanf(params, "s[63]", accept);
printf("Parameters: %s", accept);
if(IsPlayerInRangeOfPoint(playerid, 10.0, 2512.4465,-1473.9086,24.8523)) // Mechanic NPC
{
if(strcmp(accept, "accept", true) == 0)
{
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);
printf("Woops, something went wrong!");
return 1;
}
else
{
printf("Is it actually working?!");
SendClientMessage(playerid, COLOR_WHITE, "Are you sure you want the job? Type /takejob confirm");
}
}
return 1;
}
if(!strcmp(accept, "accept"))
if(strcmp(accept, "accept", true) == 0)
Try this:
pawn Код:
pawn Код:
It will help you to understand strcmp better |
COMMAND:takejob(playerid, params[])
{
if(player[playerid][ajob] != 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR » You already have a job, use /quitjob first");
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)) // Mechanic NPC
{
if(!sscanf(params, "s", accept)) //And this is changed
{
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);
printf("Woops, something went wrong!");
return 1;
}
else
{
printf("Is it actually working?!");
SendClientMessage(playerid, COLOR_WHITE, "Are you sure you want the job? Type /takejob confirm");
}
}
return 1;
}
COMMAND:takejob(playerid, params[])
{
if(player[playerid][ajob] != 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR » You already have a job, use /quitjob first");
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)) // Mechanic NPC
{
if(!sscanf(params, "s[63]", accept)) //And this is changed
{
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);
printf("Woops, something went wrong!");
return 1;
}
else
{
printf("Is it actually working?!");
SendClientMessage(playerid, COLOR_WHITE, "Are you sure you want the job? Type /takejob confirm");
}
}
return 1;
}
if (something is true ) DO SOMETHING
if (this is not true) return //something
if(IsPlayerAdmin(playerid))
{
SetPlayerMoney(playerid, 100);
printf("Player ID %d is an admin and received 100 dollar!", playerid);
}
if(!IsPlayerAdmin(playerid)) return 0; //Stop.. xD
SetPlayerMoney(playerid, 100);
printf("Player ID %d is an admin and received 100 dollar!", playerid);
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;
}
No problem
![]() And I have a little tip to make the script different. Don't use: Код:
if (something is true ) DO SOMETHING Код:
if (this is not true) return //something What you do: pawn Код:
pawn Код:
pawn Код:
But it's just an tip. Use what you like ![]() |