public OnPlayerConnect(playerid) { AlreadyFished[playerid] = 0; IsFishing[playerid] = 0; //Get fishes in file FishWeight[playerid] = GetPlayerWeight(playerid); Fishes[playerid] = GetPlayerFishes(playerid); FishingTool[playerid] = GetPlayerRod(playerid); Worms[playerid] = GetPlayerBait(playerid); return 1; }
public OnPlayerDisconnect(playerid, reason) { AlreadyFished[playerid] = 0; IsFishing[playerid] = 0; //Set fishes in file SetPlayerFishes(playerid, FishWeight[playerid], Fishes[playerid], FishingTool[playerid], Worms[playerid]); return 1; }
stock SetPlayerFishes(playerid, weight, fishes, fishingtool, worms) { new file[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "%s.ost", name); dini_IntSet(file, "Weight", weight); dini_IntSet(file, "Fishes", fishes); dini_IntSet(file, "Fishingrod", fishingtool); dini_IntSet(file, "Baits", worms); return true; } stock GetPlayerWeight(playerid) { new weight, file[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "%s.ost", name); weight = dini_Int(file, "Weight"); return weight; } stock GetPlayerFishes(playerid) { new fishes, file[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "%s.ost", name); fishes = dini_Int(file, "Fishes"); return fishes; } stock GetPlayerRod(playerid) { new rod, file[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "%s.ost", name); rod = dini_Int(file, "Fishingrod"); return rod; } stock GetPlayerBait(playerid) { new bait, file[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "%s.ost", name); bait = dini_Int(file, "Baits"); return bait; }
Weight=0 Fishes=0 Fishingrod=0 Baits=0
Try debugging line by line the stocks with the vars you would like to write in the files and show us the results.
|
printf("value: %s", thevar);
Change %s in %i if it's an integer. |
stock SetPlayerFishes(playerid, weight, fishes, fishingtool, worms) { new file[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "%s.ost", name); dini_IntSet(file, "Weight", weight); dini_IntSet(file, "Fishes", fishes); dini_IntSet(file, "Fishingrod", fishingtool); dini_IntSet(file, "Baits", worms); printf("Weight: %d, Fishes: %d, Rod: %d, Baits: %d", weight, fishes, fishingtool, worms); return true; }
printf("Weight: %d, Fishes: %d, Rod: %d, Baits: %d", weight, fishes, fishingtool, worms);
new string[128];
format(string, 128, "Weight: %d, Fishes: %d, Rod: %d, Baits: %d", weight, fishes, fishingtool, worms);
print(string);