• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Autorefundsystem errors
#1
Code:
new bool:AlreadyRefunded[ MAX_PLAYERS ];
CMD:refundme( playerid )
{
if( AlreadyRefunded[ playerid ] == true ) SendClientMessage( playerid, COLOR_GREY, "You're already refunded, what are you trying to do, mhm..?" );
else
{
PlayerInfo[playerid][pLevel] = PlayerInfo[playerid][pLevel]+3;
GiveMoney(playerid, 2500000);
PlayerInfo[playerid][pDonateRank] = 2;
format(str, 32, "%02d/%02d/%d", Month, Day, Year);
strmid(PlayerInfo[giveplayerid][pVIPJoinDate], str, 0, strlen(str), 255);
format(str, 32, "%02d/%02d/%d", Month +1, Day, Year);
strmid(PlayerInfo[giveplayerid][pVIPExpDate], str, 0, strlen(str), 255);
if(Month == 12)
{
format(PlayerInfo[giveplayerid][pVIPExpDate], 32, "%02d/%02d/%d", 1, Day, Year +1);
}
format(str, sizeof(str), "Join Date: %s, Expire Date: %s", PlayerInfo[giveplayerid][pVIPJoinDate], PlayerInfo[giveplayerid][pVIPExpDate]);
SendClientMessage(giveplayerid, COLOR_GRAD2, str);
}
return 1;
}


And the errors i get when compiling script: 
Code:
../gamemodes/inc/autorefundsys.inc(10) : error 017: undefined symbol "str"
../gamemodes/inc/autorefundsys.inc(11) : error 017: undefined symbol "str"
../gamemodes/inc/autorefundsys.inc(12) : error 017: undefined symbol "str"
../gamemodes/inc/autorefundsys.inc(13) : error 017: undefined symbol "str"
../gamemodes/inc/autorefundsys.inc(14) : error 017: undefined symbol "Month"
../gamemodes/inc/autorefundsys.inc(16) : error 017: undefined symbol "giveplayerid"
../gamemodes/inc/autorefundsys.inc(18) : error 017: undefined symbol "str"
../gamemodes/inc/autorefundsys.inc(18) : error 017: undefined symbol "str"
../gamemodes/inc/autorefundsys.inc(18) : error 029: invalid expression, assumed zero
../gamemodes/inc/autorefundsys.inc(18) : fatal error 107: too many error messages on one line

Compilation aborted.

Pawn compiler 3.10.8 Copyright (c) 1997-2006, ITB CompuPhase


10 Errors.


Im really new to scripting :D if you guys can figure this out, could you explain how do you define symbols? like str, giveplayerid?
  Reply
#2
Hello!

As your compilation log clearly states, much of these definitions are unrecognized because they haven't even been created. Also, some definitions like 'giveplayerid' seem to be useless within the bounds of this particular command. The bulk of the code seems to have been copied over from some other place where 'giveplayerid' is an actual definition, but in this case 'playerid' would work just fine.

There is, however, some scripting that needs to be done to retrieve the actual year, month and day from the supposed string of 'pVIPJoinDate' and 'pVIPExpDate'. I do not know the format of these strings, so I can't help here. However, your course of action should be to rely on 'strmid' to get the dates from the exact positions you need and then use 'strval' to convert the retrieved string pieces to values and assign them to 'Year', 'Month' and 'Day'.

This code below will not fix all your errors and warnings, but it will get you on the right track to continue scripting this command. Hope this helps.

Code:
new bool:AlreadyRefunded[ MAX_PLAYERS ];
CMD:refundme( playerid )
{
if( AlreadyRefunded[ playerid ] == true ) SendClientMessage( playerid, COLOR_GREY, "You're already refunded, what are you trying to do, mhm..?" );
else
{
new str[64], join_str[32], exp_str[32]; // create the strings at the start
PlayerInfo[playerid][pLevel] = PlayerInfo[playerid][pLevel]+3;
GivePlayerMoney(playerid, 2500000); // should probably be 'GivePlayerMoney' unless there's a new predefined function I'm not aware of
PlayerInfo[playerid][pDonateRank] = 2;
new Year, Month, Day; // create the date integers here

// 'Month', 'Day' and 'Year' probably need to be obtained from the 'pVIPJoinDate' data, possibly cut out via 'strmid'.
// This means that there needs to be some more scripting inserted right here, because currently 'Year' etc. is just equal to '0'.

format(join_str, sizeof(join_str), "%02d/%02d/%d", Month, Day, Year); // use 'join_str' and replace '32' with 'sizeof(join_str)' for convenience
strmid(PlayerInfo[playerid][pVIPJoinDate], str, 0, strlen(str), 255); // replace 'giveplayerid' with 'playerid'
format(exp_str, sizeof(exp_str), "%02d/%02d/%d", Month +1, Day, Year); // use 'exp_str' and replace '32' with 'sizeof(exp_str)' for convenience
strmid(PlayerInfo[playerid][pVIPExpDate], str, 0, strlen(str), 255); // replace 'giveplayerid' with 'playerid'
// this block of code above ^ needs to be reworked entirely

if(Month == 12)
{
format(PlayerInfo[playerid][pVIPExpDate], 64, "%02d/%02d/%d", 1, Day, Year +1); // replace 'giveplayerid' with 'playerid'
}
format(str, sizeof(str), "Join Date: %s, Expire Date: %s", PlayerInfo[playerid][pVIPJoinDate], PlayerInfo[playerid][pVIPExpDate]); // replace 'giveplayerid' with 'playerid'
SendClientMessage(playerid, COLOR_GRAD2, str); // replace 'giveplayerid' with 'playerid'
}
return 1;
}
"Those who cannot remember the past are condemned to repeat it." - George Sanatayana
  Reply


Forum Jump: