Change experience to all players MYSQL
#1

I made some changes in my gamemode and now to be fair i need to make some reset on players EXPs, in every single player get some skills and return skill = skill / 2

I've tried it, but i think i making something wrong, because i get some warnings errors

Code:
error 035: argument type mismatch (argument 2)
On line:
Code:
cache_get_value_int(0, nameOnTable, skillLVL);
Code:
CMD:reset(playerid, params[]) {
    if(admin[playerid] < 1337) return 0;
    if(admstatus[playerid] == 0) return SendClientMessage(playerid, -1, "You are in the player mode, you can not use this command! (use: /adminstats)");
    new skillselect[64], motivo[64];
    if(sscanf(params,"ss", skillselect, motivo)) {
        SendClientMessage(playerid, -1, "Use: /resetskill [skill-id] [reason]");
        return 1;
    }
    new skillLVL, userID, query[512], rows, fields, nameOnTable[64], strx[128];
    mysql_format(ConnectMYSQL, query, sizeof(query), "SELECT `experience`, `UserID` FROM `accounts`" );
    mysql_query(ConnectMYSQL,query);
    cache_get_row_count(rows);
    cache_get_field_count(fields);
    if(rows) {
        cache_get_value_int(0, "UserID", userID);
        if(!strcmp(skillselect, "lvl", true)) nameOnTable = "experience";          
        else if(!strcmp(skillselect, "respect", true)) nameOnTable = "respect";
        else if(!strcmp(skillselect, "pistol", true)) nameOnTable = "PISTOLskills";
        else if(!strcmp(skillselect, "shotgun", true)) nameOnTable = "SHOTGUNskills";
        else if(!strcmp(skillselect, "mp5", true)) nameOnTable = "MP5skills";
        else if(!strcmp(skillselect, "ak47", true)) nameOnTable = "AKskills";
        else if(!strcmp(skillselect, "m4", true)) nameOnTable = "M4skills";
        else if(!strcmp(skillselect, "rifle", true)) nameOnTable = "RIFLEskills";
        else if(!strcmp(skillselect, "sniper", true)) nameOnTable = "SNIPERskills";
        else if(!strcmp(skillselect, "minigun", true)) nameOnTable = "MINIGUNskills";
        cache_get_value_int(0, nameOnTable, skillLVL);
        skillLVL = skillLVL / 2;
        mysql_format(ConnectMYSQL, query, sizeof(query), "UPDATE `accounts` SET `%s` = '%d' WHERE `UserID` = '%d'",
            nameOnTable,
            skillLVL,
        userID);
    }
    format(strx,sizeof(strx),"AdmCmd: %s started a reset on SKILL %s. Reason: %s.", PlayerName(playerid), skillselect, (motivo));
    SendClientMessageToAll(COLOR_LIGHTRED, strx);
    writeLog("LOGS/resets.txt",strx);
    return 1;
}
Reply
#2

Quote:
Originally Posted by Y_Less
View Post
You don't need any pawn for this. You can do all of this with a single SQL UPDATE statement. SQL is a very powerful language, I suggest you read up on it some more.
Oh, thank you, i didn't know that, i'll buy a udemy course about SQL....
But could u help me to leave this problem and fix this script for reset for now?
Reply
#3

anybody?
Reply
#4

Just as the error itself tells you, you're trying to save an int value to a pre-defined string.
Code:
error 035: argument type mismatch (argument 2)
pawn Code:
cache_get_value_int(0, nameOnTable, skillLVL);
whereas
pawn Code:
new nameOnTable[64];
I'd suggest you do read up on mysql and then complete the command rather than making a temp one to later re-do it. This way is inefficient.

Also, rather use a switch() on skillselect than if/else statements, much simpler.
Reply
#5

Code:
update yourplayerstable set skill_level_name = 0
Reply
#6

Quote:
Originally Posted by introzen
View Post
Just as the error itself tells you, you're trying to save an int value to a pre-defined string.
Code:
error 035: argument type mismatch (argument 2)
pawn Code:
cache_get_value_int(0, nameOnTable, skillLVL);
whereas
pawn Code:
new nameOnTable[64];
I'd suggest you do read up on mysql and then complete the command rather than making a temp one to later re-do it. This way is inefficient.

Also, rather use a switch() on skillselect than if/else statements, much simpler.
Just like UserID, is string
cache_get_value_int(0, "UserID", userID);

And it's working...

Quote:
Originally Posted by SymonClash
View Post
Code:
update yourplayerstable set skill_level_name = 0
I dont want to set to 0, i want to get the old value and set the new value = old value / 2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)