Compiler crash (a == b) ? d : e
#1

i wanna make it simply, but i think this code is randomly stirred

checking date ban from unix timestamp, and convert to string (permanent / not)

PHP код:
public BanCheck(playerid)
{
    
// blabla
    
if(gettime unbantime
    
{
        new 
type[20], unbantime;
        
// load cache mysql & unbantime
        
format(typesizeof(type"%s", (unbantime == 0) ? ("Permanent") : (unbantime)); // this code make crash
        
        // blbla
        
new string[128];
        
format(stringsizeof(string), "Banned Type: %s"type); // this will show text from type
        // blabla
    
}
    return 
1;

Reply
#2

Firstly, when you want to insert a string into a formatting string (I don't know how to explain that), you need to put only 2 parenthesis. Since my English is so bad, I'll show what's wrong here.
PHP код:
format(typesizeof(type"%s", (unbantime == 0) ? ("Permanent") : (unbantime)); // this code make crash 
->
format(typesizeof(type"%s", (unbantime == "Permanent" unbantime)); // this code make crash 
Secondly, unbantime is an interger, but "Permanent" is a string. You cannot mix 2 types like that. You shouldn't use ternary operation here.
Reply
#3

Код:
function BanCheck(playerid)
{
    // blabla
    if(gettime < unbantime)
    {
        new type[20], unbantime;
        // load cache mysql & unbantime
        format(type, sizeof(type) "%s", (unbantime == 0) ? ("Permanent") : ("unbantime")); // this code make crash

        // blbla
        new string[128];
        format(string, sizeof(string), "Banned Type: %s", type); // this will show text from type
        // blabla
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by UFF
Посмотреть сообщение
Код:
function BanCheck(playerid)
{
    // blabla
    if(gettime < unbantime)
    {
        new type[20], unbantime;
        // load cache mysql & unbantime
        format(type, sizeof(type) "%s", (unbantime == 0) ? ("Permanent") : ("unbantime")); // this code make crash

        // blbla
        new string[128];
        format(string, sizeof(string), "Banned Type: %s", type); // this will show text from type
        // blabla
    }
    return 1;
}
it seems, not like this that I want. but thanks for giving help

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Firstly, when you want to insert a string into a formatting string (I don't know how to explain that), you need to put only 2 parenthesis. Since my English is so bad, I'll show what's wrong here.
PHP код:
format(typesizeof(type"%s", (unbantime == 0) ? ("Permanent") : (unbantime)); // this code make crash 
->
format(typesizeof(type"%s", (unbantime == "Permanent" unbantime)); // this code make crash 
Secondly, unbantime is an interger, but "Permanent" is a string. You cannot mix 2 types like that. You shouldn't use ternary operation here.
oh yea dude, after I looked over the code, it was true, I tried to put the string into integrar, so it seems I can not use code like this, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)