Like
DobbysGamertag mentioned, you already declared the 'string' variable as a global variable.
You have 2 options in this case:
1. You can change the 'string' name in your command.
2. You can just use the 'string' variable without 'recreating' it in your command.
Here are both cases:
1 - In this case, you need to change 'string' to something else, like below:
pawn Код:
if(strcmp(cmd, "/paycheck", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new astring[128]; // We changed the string name from 'string' to 'astring'
format(astring, sizeof(astring), "* You have played for %d minutes in the past hour.", PlayerInfo[playerid][pMinutes]);
if(PlayerInfo[playerid][pMinutes] < 40) SendClientMessage(playerid, COLOR_LIGHTRED, astring);
else SendClientMessage(playerid, COLOR_LIME, astring);
format(string, sizeof(string), "* You need to play for at least 40 minutes every hour to recieve a paycheck.");
SendClientMessage(playerid, COLOR_LIGHTBLUE, astring);
return 1;
}
return 1;
}
2 - You can just format the 'string' without creating it in your command, since it's already been created
pawn Код:
if(strcmp(cmd, "/paycheck", true) == 0)
{
if(IsPlayerConnected(playerid))
{
format(string, sizeof(string), "* You have played for %d minutes in the past hour.", PlayerInfo[playerid][pMinutes]);
if(PlayerInfo[playerid][pMinutes] < 40) SendClientMessage(playerid, COLOR_LIGHTRED, string);
else SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* You need to play for at least 40 minutes every hour to recieve a paycheck.");
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
return 1;
}
Even though both cases should work, I recommend you to use case 1.
Regards,
Tony