AMX Backtrace - Stats!
#1

PHP код:
YCMD:stats(playeridparams[], help) {
    if(
help) {
        
SendClientMessage(playeridX11_WHITE"Sends a player their game stats");
        return 
1;
    }
    
SendStats(playerid,playerid);
    return 
1;

PHP код:
SendStats(playerid,targetid) {
    new 
msg[508];
    
query[0] = 0;
    new 
name[250];
    if(
GetPVarInt(targetid"DonateRank") < 1)
    {
        
format(name,sizeof(name),"                                    {FF0000}%s",GetPlayerNameEx(targetid,ENameType_CharName));
    }
    if(
GetPVarInt(targetid"DonateRank") > && GetPVarInt(playerid"DonateRank") < 4)
    {
        
format(name,sizeof(name),"                                    {FFFF00}%s",GetPlayerNameEx(targetid,ENameType_CharName));
    }
    if(
GetPVarInt(targetid"DonateRank") == 4)
    {
        
format(name,sizeof(name),"                                    {FF33FF}%s",GetPlayerNameEx(targetid,ENameType_CharName));
    }
    
SendClientMessage(playeridCOLOR_WHITEmsg);
    new 
spousename[MAX_PLAYER_NAME+1];
    
GetPVarString(targetid"SpouseName"spousenamesizeof(spousename));
    
SendClientMessage(playeridCOLOR_DARKGREEN"|__________________[ %s ]__________________|",GetPlayerNameEx(playeridENameType_RPName));
    
format(msg,sizeof(msg),"EXPERIENCE: Level:[%s] Sex:[%s] Cash:[$%s] Bank:[$%s] Spouse:[%s]\n",getNumberString(GetPVarInt(targetid,"Level")),GetSexName(GetPVarInt(targetid,"Sex")),getNumberString(GetPVarInt(targetid,"Money")),getNumberString(GetPVarInt(targetid,"Bank")),spousename);
    
SendClientMessage(playeridCOLOR_GRAD1msg);
//    strcat(query, msg, sizeof(query));
    
if(GetPVarInt(targetid"DonateRank") < 1)
    {
        
format(msg,sizeof(msg),"CHARACTER: Phone Number:[%d] Lotto Number:[%d] Job:[%s]\n",GetPVarInt(targetid,"PhoneNumber"),getPlayerLottoTicket(targetid),GetJobName(GetPVarInt(targetid,"Job")));
    }
    if(
GetPVarInt(targetid"DonateRank") > && GetPVarInt(playerid"DonateRank") < 4)
    {
        
format(msg,sizeof(msg),"CHARACTER: DonateRank:[{FFFF00}%s{FFFFFF}] Donate Points:[{FFFF00}%s{FFFFFF}] Phone Number:[%d] Lotto Number:[%d] Job:[%s] Fight Style:[%s]\n",GetDonateRank(GetPVarInt(targetid,"DonateRank")),getNumberString(GetPVarInt(targetid,"DonatePoints")),GetPVarInt(targetid,"PhoneNumber"),getPlayerLottoTicket(targetid),GetJobName(GetPVarInt(targetid,"Job")),GetFightStyle(GetPVarInt(targetid"FightStyle")));
    }
    if(
GetPVarInt(targetid"DonateRank") == 4)
    {
        
format(msg,sizeof(msg),"CHARACTER: Phone Number:[%d] Lotto Number:[%d] Job:[%s]\n",GetPVarInt(targetid,"PhoneNumber"),getPlayerLottoTicket(targetid),GetJobName(GetPVarInt(targetid,"Job")));
    }
    
SendClientMessage(playeridCOLOR_GRAD2msg);
    
///strcat(query, msg, sizeof(query));
    
format(msg,sizeof(msg),"CHARACTER: Wanted Level:[%d] Times Arrested:[%s]\n",GetPlayerWantedLevel(playerid),getNumberString(GetPVarInt(targetid,"TimesArrested")));
    
SendClientMessage(playeridCOLOR_GRAD1msg);
//    strcat(query, msg, sizeof(query));
    
new nextlevel = (GetPVarInt(targetid,"Level")+1);
    new 
nextlevelcost nextlevel*levelcost;
    new 
expamount nextlevel*levelexp;
    
format(msg,sizeof(msg),"OTHER: Respect:[%s/%s] SpecialItem:[%s] Hunger:[%d]\n",getNumberString(GetPVarInt(targetid,"RespectPoints")),getNumberString(expamount),GetPlayerCarryingItemName(targetid),GetHungerLevel(targetid));
    
SendClientMessage(playeridCOLOR_GRAD2msg);
//    strcat(query, msg, sizeof(query));
    
format(msg,sizeof(msg),"INVENTORY: Cigars:[%s] LockPicks:[%s] Furniture Tokens:[%d] Walkie Talkie Channel:[%d]\n",getNumberString(GetPVarInt(targetid"Cigars")),getNumberString(GetPVarInt(targetid"VehLockpicks")),GetPVarInt(targetid"FurnitureTokens"),GetPVarInt(targetid"WTChannel"));
    
SendClientMessage(playeridCOLOR_GRAD1msg);
    
//strcat(query, msg, sizeof(query));
    
format(msg,sizeof(msg),"INVENTORY: Pot:[%s Gram] Coke:[%s Gram] Meth:[%s Gram]\n",getNumberString(GetPVarInt(targetid"Pot")),getNumberString(GetPVarInt(targetid"Coke")),getNumberString(GetPVarInt(targetid"Meth")));
    
SendClientMessage(playeridCOLOR_GRAD2msg);
//    strcat(query, msg, sizeof(query));
    
format(msg,sizeof(msg),"INVENTORY: Materials Type A:[%s Packs] Materials Type B:[%s Packs] Materials Type C:[%s Packs]\n",getNumberString(GetPVarInt(targetid"MatsA")),getNumberString(GetPVarInt(targetid"MatsB")),getNumberString(GetPVarInt(targetid"MatsC")));
    
SendClientMessage(playeridCOLOR_LIGHTREDmsg);
//    strcat(query, msg, sizeof(query));
    
new fid GetPVarInt(targetid,"Family");
    if(
fid != 0) {
        
fid FindFamilyBySQLID(fid);
    } else 
fid = -1;
    if(
fid == -&& GetPVarInt(targetid"Faction") != 0) {
        
fid GetPVarInt(targetid"Faction");
        
format(msg,sizeof(msg),"CHARACTER: Faction:[%s] Rank:[%s]\n",GetFactionName(fid),getFactionRankName(fid,GetPVarInt(targetid"Rank")));
        
SendClientMessage(playeridCOLOR_LIGHTBLUEmsg);
    
//    strcat(query, msg, sizeof(query));
        
    
} else if(fid != -1) {
        
format(msg,sizeof(msg),"CHARACTER: Family:[%s] Rank:[%s]\n",GetFamilyName(fid),getRankName(fid,GetPVarInt(targetid"Rank")));
        
SendClientMessage(playeridCOLOR_LIGHTREDmsg);
    
//    strcat(query, msg, sizeof(query));
    
}
    
format(msg,sizeof(msg),"CHARACTER: Time Played:[%s] Helper Team Rank:[%s] RP Tokens:[%s]\n",getNumberString(GetPVarInt(targetid,"ConnectTime")),GetNewbieName(targetid),getNumberString(GetPVarInt(targetid,"Cookies")));
    
SendClientMessage(playeridCOLOR_GRAD1msg);
    
//strcat(query, msg, sizeof(query));
    
    
new matpacks[3], drugpacks[3];
    
matpacks[0] = GetPVarInt(playerid"MatAPacks");
    
matpacks[1] = GetPVarInt(playerid"MatBPacks");
    
matpacks[2] = GetPVarInt(playerid"MatCPacks");
    
drugpacks[0] = GetPVarInt(playerid"PotSeeds");
    
drugpacks[1] = GetPVarInt(playerid"CokePlants");
    
drugpacks[2] = GetPVarInt(playerid"MethMaterials");
    if(
matpacks[0] != || matpacks[1] != || matpacks[2] != 0) {
        
format(msg,sizeof(msg),"INVENTORY: MatAPacks:[%s] MatBPacks:[%s] MatCPacks:[%s]\n",getNumberString(matpacks[0]),getNumberString(matpacks[1]),getNumberString(matpacks[2]));
        
SendClientMessage(playeridCOLOR_LIGHTREDmsg);
        
//strcat(query, msg, sizeof(query));
    
}
    
    if(
drugpacks[0] != || drugpacks[1] != || drugpacks[2] != 0) {
        
format(msg,sizeof(msg),"INVENTORY: PotSeeds:[%s] CokePlants:[%s] MethMaterials:[%s]\n",getNumberString(drugpacks[0]),getNumberString(drugpacks[1]),getNumberString(drugpacks[2]));
        
SendClientMessage(playeridCOLOR_LIGHTREDmsg);
        
//strcat(query, msg, sizeof(query));
    
}
    
    new 
jailtime GetPVarInt(targetid"ReleaseTime");
    new 
isajail;
    if(
jailtime == 0) {
        
jailtime GetPVarInt(targetid"AJailReleaseTime");
        
isajail 1;
    }
    
jailtime -= gettime();
    if(
jailtime 0) {
        
format(msgsizeof(msg), "{FFFFFF}Jail Time Left: %s sec\n"getNumberString(jailtime));
        
SendClientMessage(playeridisajail?COLOR_LIGHTRED:COLOR_WHITEmsg);
        
//strcat(query, msg, sizeof(query));
    
}
    if(
EAdminFlags:GetPVarInt(playerid"AdminFlags") != EAdminFlags_None) {
        
format(msgsizeof(msg), "OTHER: NumAJails:[%s] NumKicks:[%s] NumBans[%s] Wealth:[%s]\n",getNumberString(GetPVarInt(targetid"NumAJAils")),getNumberString(GetPVarInt(targetid"NumKicks")), getNumberString(GetPVarInt(targetid"NumBans")),getNumberString(getTotalWealth(targetid)));
        
SendClientMessage(playeridCOLOR_LIGHTREDmsg);
        
//strcat(query, msg, sizeof(query));
    
}
    
//ShowPlayerDialog(playerid, ERP_ViewStats, DIALOG_STYLE_MSGBOX, name,query,"Close", "");
    
SendClientMessage(playeridCOLOR_DARKGREEN"|__________________[ %s ]__________________|"GetPlayerNameEx(playeridENameType_RPName));

I'm getting an AMX Backtrace.. bcz of this.. can't find what's wrong.. please help thanks.
Reply
#2

Disregard!
Reply
#3

Quote:
Originally Posted by Twizted
Посмотреть сообщение
Any speficic reason as to why you are not doing this in the /stats command?

pawn Код:
SendStats(playerid,targetid);
Can't it says undefined symbol: targetid..
Reply
#4

Quote:
Originally Posted by Twizted
Посмотреть сообщение
Any speficic reason as to why you are not doing this in the /stats command?

pawn Код:
SendStats(playerid,targetid);
woh, u so pro !

OT: Well, It'll be a bit hard to understand that where's the problem but you can try debugging at some part of the code.
e.g
Код:
GetPVarString(targetid, "SpouseName", spousename, sizeof(spousename)); 
print("Reached Part 1.");
This would be helpful, So that when whenever you recieves the AMX backtrace error, You can see that which code is printed, and which code is printed after the error.
That's the best way,
Reply
#5

compile the code with -d3 flag and use crash detect to get exact line causing crash.
Reply
#6

Found the problem.. its with these lines:

PHP код:
SendClientMessage(playeridCOLOR_DARKGREEN,"|____________________[ %s ]____________________|",GetPlayerNameEx(playeridENameType_CharName)); 
No idea why this line is causing the problem.. I really want to add the character name up there..
Reply
#7

Probably because SendClientMessage does not support specifiers?
Reply
#8

Quote:
Originally Posted by Freshncool
Посмотреть сообщение
Probably because SendClientMessage does not support specifiers?
It works if I add it like this:

PHP код:
SendClientMessage(playeridCOLOR_DARKGREEN,"|________________________________________|"); 
without char name..
Reply
#9

Код:
format(msg,sizeof(msg),"|____________________[ %s ]____________________|",GetPlayerNameEx(playerid, ENameType_CharName));
SendClientMessage(playerid,COLOR_DARKGREEN,msg);
You can't use specifiers in normal message, Could be done using format.
Reply
#10

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Код:
format(msg,sizeof(msg),"|____________________[ %s ]____________________|",GetPlayerNameEx(playerid, ENameType_CharName));
SendClientMessage(playerid,COLOR_DARKGREEN,msg);
You can't use specifiers in normal message, Could be done using format.
Yup, thank you though, fixed it before you replied :P still +REP all of u xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)