Need Little help with Y_Ini For my GameMode -
DheWardhana - 06.11.2013
I tired to fix this problem, Im newbie with y_ini becaues this before i use dini. anyone can help my problem?

REP++ Who can help me
No Steal please
Код:
//includes
#include <a_samp>
#include <zcmd>
#include <colors>
#include <mSelection>
#include <YSI\y_ini>
//defines
#define register 1
#define login 2
#define UserPath "/%s.ini"
#define PATH "/%s.ini"
native WP_Hash(buffer[],len,const str[]);
enum PlayerInfo
{
Pass[129], //User's password
Adminlevel, //User's admin level
VIPlevel, //User's vip level
Money, //User's money
Scores, //User's scores
Kills, //User's kills
Deaths //User's deaths
}
enum wInfo {
// Weapons
Weapon1,
Weapon2,
Weapon3,
Weapon4,
Weapon5,
Weapon6,
Weapon7,
Weapon8,
Weapon9,
Weapon10,
Weapon11,
Weapon12,
//Ammo
Ammo1,
Ammo2,
Ammo3,
Ammo4,
Ammo5,
Ammo6,
Ammo7,
Ammo8,
Ammo9,
Ammo10,
Ammo11,
Ammo12,
}
new WeaponInfo[MAX_PLAYERS][wInfo];
new pInfo[MAX_PLAYERS][PlayerInfo];
new Float:posX[MAX_PLAYERS];
new Float:posY[MAX_PLAYERS];
new Float:posZ[MAX_PLAYERS];
new Float:posA[MAX_PLAYERS];
new Interior[MAX_PLAYERS];
new VirtualWorld[MAX_PLAYERS];
new Saved[MAX_PLAYERS];
new Text:ShadowsRandom;
new vehiclelist = mS_INVALID_LISTID;
new skinlist = mS_INVALID_LISTID;
new weaponlist = mS_INVALID_LISTID;
forward RandomMessage();
forward loadaccount_user(playerid, name[], value[]);
//Stock Functions
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),UserPath,name);
return str;
}
stock NoMinus(string[])
{
for(new i; i < strlen(string); i++)
{
if(string[i] == '-')
{
strdel(string, i, i+1);
}
}
return string;
}
stock pWeaponSave(playerid)
{
new string[50];
format(string, sizeof(string), PATH, GetName(playerid));
return string;
}
//Commands
CMD:weapon(playerid, params[])
{
ShowModelSelectionMenu(playerid, weaponlist, "Weapon:");
return 1;
}
CMD:vehicle(playerid, params[])
{
ShowModelSelectionMenu(playerid, vehiclelist, "Vehicle:");
return 1;
}
CMD:skin(playerid, params[])
{
ShowModelSelectionMenu(playerid, skinlist, "Select Skin:");
return 1;
}
CMD:kill(playerid, params[])
{
SetPlayerHealth(playerid, 0);
return 1;
}
CMD:s(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, posX[playerid], posY[playerid], posZ[playerid]);
GetVehicleZAngle(vehicleid, posA[playerid]);
}
else
{
GetPlayerPos(playerid, posX[playerid], posY[playerid], posZ[playerid]);
GetPlayerFacingAngle(playerid, posA[playerid]);
}
Interior[playerid] = GetPlayerInterior(playerid);
VirtualWorld[playerid] = GetPlayerVirtualWorld(playerid);
SendClientMessage(playerid, -1, "Kamu telah menyimpan posisimu");
SendClientMessage(playerid, -1, "Gunakan /r, /loadpos Untuk memuat posisi yang disimpan!");
Saved[playerid] = 1;
return 1;
}
stock GetName(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
CMD:savepos(playerid, params[])
{
return cmd_s(playerid, params);
}
CMD:r(playerid, params[])
{
if(Saved[playerid] == 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
SetVehiclePos(vehicleid, posX[playerid], posY[playerid], posZ[playerid]);
SetVehicleZAngle(vehicleid, posA[playerid]);
LinkVehicleToInterior(vehicleid, Interior[playerid]);
SetVehicleVirtualWorld(vehicleid, VirtualWorld[playerid]);
}
else
{
SetPlayerPos(playerid, posX[playerid], posY[playerid], posZ[playerid]);
SetPlayerFacingAngle(playerid, posA[playerid]);
SetPlayerInterior(playerid, Interior[playerid]);
SetPlayerVirtualWorld(playerid, VirtualWorld[playerid]);
}
SendClientMessage(playerid, -1, "Kamu telah memuat posisimu");
SendClientMessage(playerid, -1, "Gunakan /s, /savepos Untuk menyimpan posisi yang disimpan!");
}
else
{
SendClientMessage(playerid, -1, "ERROR: Kamu belum pernah menyimpan posisi sebelumnya!");
SendClientMessage(playerid, -1, "Gunakan /s, /savepos Untuk menyimpan posisi yang disimpan");
}
return 1;
}
CMD:loadpos(playerid, params[])
{
return cmd_r(playerid, params);
}
CMD:v(playerid, params[])
{
return cmd_v(playerid, params);
}
CMD:w(playerid, params[])
{
return cmd_w(playerid, params);
}
new RandomMessages[][] =
{
"Menggunakan Program ilegal akan kami BANNED! /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
"No SARA No JUNK No SPAWNKILL, Just PLAY AND FUN! /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
"Server Ini Masih dalam Keadaan BETA! /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
"Dibutuhkan ADMIN Segera, Hub: DheWardhana(OWNER)! /skin(kostum) /vehicle(kendaraan) /weapon(senjata)"
};
public RandomMessage()
{
TextDrawSetString(ShadowsRandom, RandomMessages[random(sizeof(RandomMessages))]);
return 1;
}
main()
{
print("\n----------------------------------");
print(" Stepn'One GAMEMODE Script's");
print(" Weapon System: ADDED!");
print(" Vehicle System: ADDED!");
print(" Skin System: ADDED!");
print(" Admin System: NOTYET!");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetNameTagDrawDistance(40.0);
EnableStuntBonusForAll(0);
SetWeather(2);
SetWorldTime(11);
vehiclelist = LoadModelSelectionMenu("vehicle.txt");
skinlist = LoadModelSelectionMenu("skins.txt");
weaponlist = LoadModelSelectionMenu("weapons.txt");
ShowPlayerMarkers(1);
ShowNameTags(1);
SetTimer("RandomMessage",3000,1);
ShadowsRandom = TextDrawCreate(18.000000,428.000000,"Selamat datang di Step'nOne SAMP /skin(kostum) /vehicle(kendaraan) /weapon(senjata)");
TextDrawAlignment(ShadowsRandom,0);
TextDrawBackgroundColor(ShadowsRandom,0x000000ff);
TextDrawFont(ShadowsRandom,2);
TextDrawLetterSize(ShadowsRandom,0.199999,0.899999);
TextDrawColor(ShadowsRandom,0xffffffff);
TextDrawSetOutline(ShadowsRandom,1);
TextDrawSetProportional(ShadowsRandom,1);
TextDrawSetShadow(ShadowsRandom,1);
SetGameModeText("STEPNONE GAMEMODE!");
for(new s = 0; s < 300; s++)
{
if(IsInvalidSkin(s)) continue;
else AddPlayerClass(s, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
}
return 1;
}
stock IsInvalidSkin(skinid)
{
#define MAX_BAD_SKINS 15
if(skinid > 310) return true;
new badSkins[MAX_BAD_SKINS] = {
3, 4, 5, 6, 8, 42, 65, 74, 86,
119, 149, 208, 273, 289, 0
};
for (new i = 0; i < MAX_BAD_SKINS; i++)
{
if (skinid == badSkins[i]) return true;
}
return false;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384);
SetPlayerFacingAngle(playerid,0.0);
return 1;
}
public OnPlayerConnect(playerid)
{
posX[playerid] = 0.000000, posY[playerid] = 0.000000, posZ[playerid] = 0.000000;
posA[playerid] = 0.000000, Interior[playerid] = 0, VirtualWorld[playerid] = 0;
Saved[playerid] = 0;
new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
GetPlayerName(playerid,name,sizeof(name)); //Get player's name
if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
{// then
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
}
else //If the connected user is not registered,
{//then we will 'force' him to register :)
ShowPlayerDialog(playerid,register,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
return 1;
}
if(!fexist(pWeaponSave(playerid)))
{
new INI:file = INI_Open(pWeaponSave(playerid));
// Weapon Create
INI_WriteInt(file, "Weapon1", 0);
INI_WriteInt(file, "Weapon2", 0);
INI_WriteInt(file, "Weapon3", 0);
INI_WriteInt(file, "Weapon4", 0);
INI_WriteInt(file, "Weapon5", 0);
INI_WriteInt(file, "Weapon6", 0);
INI_WriteInt(file, "Weapon7", 0);
INI_WriteInt(file, "Weapon8", 0);
INI_WriteInt(file, "Weapon9", 0);
INI_WriteInt(file, "Weapon10", 0);
INI_WriteInt(file, "Weapon11", 0);
INI_WriteInt(file, "Weapon12", 0);
// Ammo Create
INI_WriteInt(file, "Ammo1", 0);
INI_WriteInt(file, "Ammo2", 0);
INI_WriteInt(file, "Ammo3", 0);
INI_WriteInt(file, "Ammo4", 0);
INI_WriteInt(file, "Ammo5", 0);
INI_WriteInt(file, "Ammo6", 0);
INI_WriteInt(file, "Ammo7", 0);
INI_WriteInt(file, "Ammo8", 0);
INI_WriteInt(file, "Ammo9", 0);
INI_WriteInt(file, "Ammo10", 0);
INI_WriteInt(file, "Ammo11", 0);
INI_WriteInt(file, "Ammo12", 0);
INI_Close(file);
INI_ParseFile(pWeaponSave(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else if(fexist(pWeaponSave(playerid)))
{
INI_ParseFile(pWeaponSave(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
GetPlayerWeaponData(playerid, 1, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
GetPlayerWeaponData(playerid, 2, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
GetPlayerWeaponData(playerid, 3, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
GetPlayerWeaponData(playerid, 4, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
GetPlayerWeaponData(playerid, 5, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
GetPlayerWeaponData(playerid, 6, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
GetPlayerWeaponData(playerid, 7, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
GetPlayerWeaponData(playerid, 8, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
GetPlayerWeaponData(playerid, 9, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
GetPlayerWeaponData(playerid, 10, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
GetPlayerWeaponData(playerid, 11, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
GetPlayerWeaponData(playerid, 12, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);
if(fexist(pWeaponSave(playerid)))
new INI:file = INI_Open(pWeaponSave(playerid));
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
// Weapon Save
INI_WriteInt(file, "Weapon1", WeaponInfo[playerid][Weapon1]);
INI_WriteInt(file, "Weapon2", WeaponInfo[playerid][Weapon2]);
INI_WriteInt(file, "Weapon3", WeaponInfo[playerid][Weapon3]);
INI_WriteInt(file, "Weapon4", WeaponInfo[playerid][Weapon4]);
INI_WriteInt(file, "Weapon5", WeaponInfo[playerid][Weapon5]);
INI_WriteInt(file, "Weapon6", WeaponInfo[playerid][Weapon6]);
INI_WriteInt(file, "Weapon7", WeaponInfo[playerid][Weapon7]);
INI_WriteInt(file, "Weapon8", WeaponInfo[playerid][Weapon8]);
INI_WriteInt(file, "Weapon9", WeaponInfo[playerid][Weapon9]);
INI_WriteInt(file, "Weapon10", WeaponInfo[playerid][Weapon10]);
INI_WriteInt(file, "Weapon11", WeaponInfo[playerid][Weapon11]);
INI_WriteInt(file, "Weapon12", WeaponInfo[playerid][Weapon12]);
// Ammo Save
INI_WriteInt(file, "Ammo1", WeaponInfo[playerid][Ammo1]);
INI_WriteInt(file, "Ammo2", WeaponInfo[playerid][Ammo2]);
INI_WriteInt(file, "Ammo3", WeaponInfo[playerid][Ammo3]);
INI_WriteInt(file, "Ammo4", WeaponInfo[playerid][Ammo4]);
INI_WriteInt(file, "Ammo5", WeaponInfo[playerid][Ammo5]);
INI_WriteInt(file, "Ammo6", WeaponInfo[playerid][Ammo6]);
INI_WriteInt(file, "Ammo7", WeaponInfo[playerid][Ammo7]);
INI_WriteInt(file, "Ammo8", WeaponInfo[playerid][Ammo8]);
INI_WriteInt(file, "Ammo9", WeaponInfo[playerid][Ammo9]);
INI_WriteInt(file, "Ammo10", WeaponInfo[playerid][Ammo10]);
INI_WriteInt(file, "Ammo11", WeaponInfo[playerid][Ammo11]);
INI_WriteInt(file, "Ammo12", WeaponInfo[playerid][Ammo12]);
INI_Close(file);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);
new PlayerName[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "%s Telah Respawn.", PlayerName);
SendClientMessageToAll(COLOR_RED, string);
TextDrawShowForPlayer(playerid, ShadowsRandom);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
pInfo[killerid][Kills]++;//Will give 1 kill to killer and it will be saved inside of his/her account
pInfo[playerid][Deaths]++;
SendDeathMessage(killerid, playerid, reason);
return 1;
}
public OnPlayerModelSelection(playerid, response, listid, modelid)
{
if(listid == vehiclelist)
{
if(response)
{
SendClientMessage(playerid, 0xFF0000FF, "Kendaraan Muncul!");
new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
CreateVehicle(modelid, pos[0] + 2.5, pos[1], pos[2] + 2.5, 0.0, random(128), random(128), -1);
}
else SendClientMessage(playerid, 0xFF0000FF, "Mematalkan Pemilihan Kendaraan");
return 1;
}
if(listid == skinlist)
{
if(response)
{
SendClientMessage(playerid, 0xFF0000FF, "Skin Terganti!");
SetPlayerSkin(playerid, modelid);
}
else SendClientMessage(playerid, 0xFF0000FF, "Membatalkan Pemilihan Skin");
return 1;
}
if(listid == weaponlist)
{
if(modelid==331) //1 knuckle
{
if(GetPlayerMoney(playerid) <450) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Brass Knuckles dengan $450");
GivePlayerMoney(playerid, -450);
GivePlayerWeapon(playerid, 1, 9999);
}
if(modelid==335) //4 pisau
{
if(GetPlayerMoney(playerid) <750) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Knife dengan $750");
GivePlayerMoney(playerid, -750);
GivePlayerWeapon(playerid, 4, 9999);
}
if(modelid==339) //8 katana
{
if(GetPlayerMoney(playerid) <1000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Katana dengan $1000");
GivePlayerMoney(playerid, -1000);
GivePlayerWeapon(playerid, 8, 9999);
}
if(modelid==346) //22 9mm
{
if(GetPlayerMoney(playerid) <3500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Pistol 9mm dengan $3500");
GivePlayerMoney(playerid, -3500);
GivePlayerWeapon(playerid, 22, 350);
}
if(modelid==347) //23 silenced 9mm
{
if(GetPlayerMoney(playerid) <5000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Pistol Silenced 9mm dengan $5000");
GivePlayerMoney(playerid, -5000);
GivePlayerWeapon(playerid, 23, 350);
}
if(modelid==348) //24 Deagle
{
if(GetPlayerMoney(playerid) <8000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Deagle Pistol dengan $8000");
GivePlayerMoney(playerid, -8000);
GivePlayerWeapon(playerid, 24, 200);
}
if(modelid==349) //25 Shotgun
{
if(GetPlayerMoney(playerid) <6000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Shotgun dengan $6000");
GivePlayerMoney(playerid, -6000);
GivePlayerWeapon(playerid, 25, 80);
}
if(modelid==350) //26 Sawnoff Shotgun
{
if(GetPlayerMoney(playerid) <8000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Sawnoff Shotgun dengan $8000");
GivePlayerMoney(playerid, -8000);
GivePlayerWeapon(playerid, 26, 80);
}
if(modelid==351) //27 auto Shotgun
{
if(GetPlayerMoney(playerid) <10000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Combat Shotgun dengan $10000");
GivePlayerMoney(playerid, -10000);
GivePlayerWeapon(playerid, 27, 80);
}
if(modelid==352)
{
if(GetPlayerMoney(playerid) <7500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Uzi dengan $5000");
GivePlayerMoney(playerid, -7500);
GivePlayerWeapon(playerid, 28, 650);
}
if(modelid==356)
{
if(GetPlayerMoney(playerid) <22500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli M4 Maverick dengan $22500");
GivePlayerMoney(playerid, -22500);
GivePlayerWeapon(playerid, 31, 400);
}
if(modelid==357)
{
if(GetPlayerMoney(playerid) <15000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Gun Rifle dengan $15000");
GivePlayerMoney(playerid, -15000);
GivePlayerWeapon(playerid, 33, 50);
}
if(modelid==358)
{
if(GetPlayerMoney(playerid) <17500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Sniper Rifle dengan $17500");
GivePlayerMoney(playerid, -17500);
GivePlayerWeapon(playerid, 34, 40);
}
if(modelid==359)
{
if(GetPlayerMoney(playerid) <100000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli RPG dengan $100000");
GivePlayerMoney(playerid, -100000);
GivePlayerWeapon(playerid, 35, 10);
}
if(modelid==367)
{
if(GetPlayerMoney(playerid) <7500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Canon 1DX dengan $7500");
GivePlayerMoney(playerid, -7500);
GivePlayerWeapon(playerid, 43, 1000);
}
if(modelid==371)
{
if(GetPlayerMoney(playerid) <600) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Parachute dengan $6000");
GivePlayerMoney(playerid, -6000);
GivePlayerWeapon(playerid, 46, 1);
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == register) //If dialog id is a register dialog
{//then
if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
if(response) //if they clicked the first button "Register"
{//then
if(!strlen(inputtext)) //If they didn't enter any password
{// then we will tell to them to enter the password to register
ShowPlayerDialog(playerid,register,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
return 1;
}
//If they have entered a correct password for his/her account...
new hashpass[129]; //Now we will create a new variable to hash his/her password
WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
INI_WriteInt(file,"VIPLevel",0);//As explained above
INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
INI_WriteInt(file,"Kills",0);//As explained above
INI_WriteInt(file,"Deaths",0);//As explained above
INI_Close(file);//Now after we've done saving their data, we now need to close the file
SendClientMessage(playerid,-1,"You have been successfully registered");//Tell to them that they have successfully registered a new account
return 1;
}
}
if(dialogid == login) //If dialog id is a login dialog
{//then
if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
if(response) //if they clicked the first button "Register"
{//then
new hashpass[129]; //Will create a new variable to hash his/her password
WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
{//then
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
}
else //If they've entered an incorrect password
{//then
ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
return 1;
}
}
}
return 1;
}
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_Int("Money",pInfo[playerid][Money]); //As explained above
INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
INI_Int("Weapon1", WeaponInfo[playerid][Weapon1]);
INI_Int("Weapon2", WeaponInfo[playerid][Weapon2]);
INI_Int("Weapon3", WeaponInfo[playerid][Weapon3]);
INI_Int("Weapon4", WeaponInfo[playerid][Weapon4]);
INI_Int("Weapon5", WeaponInfo[playerid][Weapon5]);
INI_Int("Weapon6", WeaponInfo[playerid][Weapon6]);
INI_Int("Weapon7", WeaponInfo[playerid][Weapon7]);
INI_Int("Weapon8", WeaponInfo[playerid][Weapon8]);
INI_Int("Weapon9", WeaponInfo[playerid][Weapon9]);
INI_Int("Weapon10", WeaponInfo[playerid][Weapon10]);
INI_Int("Weapon11", WeaponInfo[playerid][Weapon11]);
INI_Int("Weapon12", WeaponInfo[playerid][Weapon12]);
// Load Ammo
INI_Int("Ammo1", WeaponInfo[playerid][Ammo1]);
INI_Int("Ammo2", WeaponInfo[playerid][Ammo2]);
INI_Int("Ammo3", WeaponInfo[playerid][Ammo3]);
INI_Int("Ammo4", WeaponInfo[playerid][Ammo4]);
INI_Int("Ammo5", WeaponInfo[playerid][Ammo5]);
INI_Int("Ammo6", WeaponInfo[playerid][Ammo6]);
INI_Int("Ammo7", WeaponInfo[playerid][Ammo7]);
INI_Int("Ammo8", WeaponInfo[playerid][Ammo8]);
INI_Int("Ammo9", WeaponInfo[playerid][Ammo9]);
INI_Int("Ammo10", WeaponInfo[playerid][Ammo10]);
INI_Int("Ammo11", WeaponInfo[playerid][Ammo11]);
INI_Int("Ammo12", WeaponInfo[playerid][Ammo12]);
return 1;
}
And my problem is.
Код:
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn.pwn(366) : error 003: declaration of a local variable must appear in a compound block
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn.pwn(366) : warning 221: label name "INI" shadows tag name
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn.pwn(366) : error 017: undefined symbol "file"
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn.pwn(366) : warning 203: symbol is never used: "INI"
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn.pwn(366 -- 403) : error 010: invalid function or declaration
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn.pwn(366 -- 403) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: Need Little help with Y_Ini For my GameMode -
DheWardhana - 06.11.2013
Help Pleaseeee
Re: Need Little help with Y_Ini For my GameMode -
Scrillex - 06.11.2013
Post out the error line mate

that would be much easier to help.
Here is full your code:
pawn Код:
//includes
#include <a_samp>
#include <zcmd>
#include <colors>
#include <mSelection>
#include <YSI\y_ini>
//defines
#define register 1
#define login 2
#define UserPath "/%s.ini"
#define PATH "/%s.ini"
native WP_Hash(buffer[],len,const str[]);
enum PlayerInfo
{
Pass[129], //User's password
Adminlevel, //User's admin level
VIPlevel, //User's vip level
Money, //User's money
Scores, //User's scores
Kills, //User's kills
Deaths //User's deaths
}
enum wInfo {
// Weapons
Weapon1,
Weapon2,
Weapon3,
Weapon4,
Weapon5,
Weapon6,
Weapon7,
Weapon8,
Weapon9,
Weapon10,
Weapon11,
Weapon12,
//Ammo
Ammo1,
Ammo2,
Ammo3,
Ammo4,
Ammo5,
Ammo6,
Ammo7,
Ammo8,
Ammo9,
Ammo10,
Ammo11,
Ammo12,
}
new WeaponInfo[MAX_PLAYERS][wInfo];
new pInfo[MAX_PLAYERS][PlayerInfo];
new Float:posX[MAX_PLAYERS];
new Float:posY[MAX_PLAYERS];
new Float:posZ[MAX_PLAYERS];
new Float:posA[MAX_PLAYERS];
new Interior[MAX_PLAYERS];
new VirtualWorld[MAX_PLAYERS];
new Saved[MAX_PLAYERS];
new Text:ShadowsRandom;
new vehiclelist = mS_INVALID_LISTID;
new skinlist = mS_INVALID_LISTID;
new weaponlist = mS_INVALID_LISTID;
forward RandomMessage();
forward loadaccount_user(playerid, name[], value[]);
new RandomMessages[][] =
{
"Menggunakan Program ilegal akan kami BANNED! /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
"No SARA No JUNK No SPAWNKILL, Just PLAY AND FUN! /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
"Server Ini Masih dalam Keadaan BETA! /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
"Dibutuhkan ADMIN Segera, Hub: DheWardhana(OWNER)! /skin(kostum) /vehicle(kendaraan) /weapon(senjata)"
};
main()
{
print("\n----------------------------------");
print(" Stepn'One GAMEMODE Script's");
print(" Weapon System: ADDED!");
print(" Vehicle System: ADDED!");
print(" Skin System: ADDED!");
print(" Admin System: NOTYET!");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetNameTagDrawDistance(40.0);
EnableStuntBonusForAll(0);
SetWeather(2);
SetWorldTime(11);
vehiclelist = LoadModelSelectionMenu("vehicle.txt");
skinlist = LoadModelSelectionMenu("skins.txt");
weaponlist = LoadModelSelectionMenu("weapons.txt");
ShowPlayerMarkers(1);
ShowNameTags(1);
SetTimer("RandomMessage",3000,1);
ShadowsRandom = TextDrawCreate(18.000000,428.000000,"Selamat datang di Step'nOne SAMP /skin(kostum) /vehicle(kendaraan) /weapon(senjata)");
TextDrawAlignment(ShadowsRandom,0);
TextDrawBackgroundColor(ShadowsRandom,0x000000ff);
TextDrawFont(ShadowsRandom,2);
TextDrawLetterSize(ShadowsRandom,0.199999,0.899999);
TextDrawColor(ShadowsRandom,0xffffffff);
TextDrawSetOutline(ShadowsRandom,1);
TextDrawSetProportional(ShadowsRandom,1);
TextDrawSetShadow(ShadowsRandom,1);
SetGameModeText("STEPNONE GAMEMODE!");
for(new s = 0; s < 300; s++)
{
if(IsInvalidSkin(s)) continue;
else AddPlayerClass(s, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
}
return 1;
}
stock IsInvalidSkin(skinid)
{
#define MAX_BAD_SKINS 15
if(skinid > 310) return true;
new badSkins[MAX_BAD_SKINS] = {
3, 4, 5, 6, 8, 42, 65, 74, 86,
119, 149, 208, 273, 289, 0
};
for (new i = 0; i < MAX_BAD_SKINS; i++)
{
if (skinid == badSkins[i]) return true;
}
return false;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384);
SetPlayerFacingAngle(playerid,0.0);
return 1;
}
public OnPlayerConnect(playerid)
{
posX[playerid] = 0.000000, posY[playerid] = 0.000000, posZ[playerid] = 0.000000;
posA[playerid] = 0.000000, Interior[playerid] = 0, VirtualWorld[playerid] = 0;
Saved[playerid] = 0;
new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
GetPlayerName(playerid,name,sizeof(name)); //Get player's name
if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
{// then
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
}
else //If the connected user is not registered,
{//then we will 'force' him to register :)
ShowPlayerDialog(playerid,register,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
return 1;
}
if(!fexist(pWeaponSave(playerid)))
{
new INI:wfile = INI_Open(pWeaponSave(playerid));
// Weapon Create
INI_WriteInt(wfile, "Weapon1", 0);
INI_WriteInt(wfile, "Weapon2", 0);
INI_WriteInt(wfile, "Weapon3", 0);
INI_WriteInt(wfile, "Weapon4", 0);
INI_WriteInt(wfile, "Weapon5", 0);
INI_WriteInt(wfile, "Weapon6", 0);
INI_WriteInt(wfile, "Weapon7", 0);
INI_WriteInt(wfile, "Weapon8", 0);
INI_WriteInt(wfile, "Weapon9", 0);
INI_WriteInt(wfile, "Weapon10", 0);
INI_WriteInt(wfile, "Weapon11", 0);
INI_WriteInt(wfile, "Weapon12", 0);
// Ammo Create
INI_WriteInt(wfile, "Ammo1", 0);
INI_WriteInt(wfile, "Ammo2", 0);
INI_WriteInt(wfile, "Ammo3", 0);
INI_WriteInt(wfile, "Ammo4", 0);
INI_WriteInt(wfile, "Ammo5", 0);
INI_WriteInt(wfile, "Ammo6", 0);
INI_WriteInt(wfile, "Ammo7", 0);
INI_WriteInt(wfile, "Ammo8", 0);
INI_WriteInt(wfile, "Ammo9", 0);
INI_WriteInt(wfile, "Ammo10", 0);
INI_WriteInt(wfile, "Ammo11", 0);
INI_WriteInt(wfile, "Ammo12", 0);
INI_Close(wfile);
INI_ParseFile(pWeaponSave(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else if(fexist(pWeaponSave(playerid)))
{
INI_ParseFile(pWeaponSave(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
GetPlayerWeaponData(playerid, 1, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
GetPlayerWeaponData(playerid, 2, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
GetPlayerWeaponData(playerid, 3, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
GetPlayerWeaponData(playerid, 4, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
GetPlayerWeaponData(playerid, 5, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
GetPlayerWeaponData(playerid, 6, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
GetPlayerWeaponData(playerid, 7, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
GetPlayerWeaponData(playerid, 8, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
GetPlayerWeaponData(playerid, 9, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
GetPlayerWeaponData(playerid, 10, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
GetPlayerWeaponData(playerid, 11, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
GetPlayerWeaponData(playerid, 12, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
new INI:wfile = INI_Open(pWeaponSave(playerid));
if(fexist(pWeaponSave(playerid)))
{
// Weapon Save
INI_WriteInt(wfile, "Weapon1", WeaponInfo[playerid][Weapon1]);
INI_WriteInt(wfile, "Weapon2", WeaponInfo[playerid][Weapon2]);
INI_WriteInt(wfile, "Weapon3", WeaponInfo[playerid][Weapon3]);
INI_WriteInt(wfile, "Weapon4", WeaponInfo[playerid][Weapon4]);
INI_WriteInt(wfile, "Weapon5", WeaponInfo[playerid][Weapon5]);
INI_WriteInt(wfile, "Weapon6", WeaponInfo[playerid][Weapon6]);
INI_WriteInt(wfile, "Weapon7", WeaponInfo[playerid][Weapon7]);
INI_WriteInt(wfile, "Weapon8", WeaponInfo[playerid][Weapon8]);
INI_WriteInt(wfile, "Weapon9", WeaponInfo[playerid][Weapon9]);
INI_WriteInt(wfile, "Weapon10", WeaponInfo[playerid][Weapon10]);
INI_WriteInt(wfile, "Weapon11", WeaponInfo[playerid][Weapon11]);
INI_WriteInt(wfile, "Weapon12", WeaponInfo[playerid][Weapon12]);
// Ammo Save
INI_WriteInt(wfile, "Ammo1", WeaponInfo[playerid][Ammo1]);
INI_WriteInt(wfile, "Ammo2", WeaponInfo[playerid][Ammo2]);
INI_WriteInt(wfile, "Ammo3", WeaponInfo[playerid][Ammo3]);
INI_WriteInt(wfile, "Ammo4", WeaponInfo[playerid][Ammo4]);
INI_WriteInt(wfile, "Ammo5", WeaponInfo[playerid][Ammo5]);
INI_WriteInt(wfile, "Ammo6", WeaponInfo[playerid][Ammo6]);
INI_WriteInt(wfile, "Ammo7", WeaponInfo[playerid][Ammo7]);
INI_WriteInt(wfile, "Ammo8", WeaponInfo[playerid][Ammo8]);
INI_WriteInt(wfile, "Ammo9", WeaponInfo[playerid][Ammo9]);
INI_WriteInt(wfile, "Ammo10", WeaponInfo[playerid][Ammo10]);
INI_WriteInt(wfile, "Ammo11", WeaponInfo[playerid][Ammo11]);
INI_WriteInt(wfile, "Ammo12", WeaponInfo[playerid][Ammo12]);
INI_Close(wfile);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);
new PlayerName[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "%s Telah Respawn.", PlayerName);
SendClientMessageToAll(COLOR_RED, string);
TextDrawShowForPlayer(playerid, ShadowsRandom);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
pInfo[killerid][Kills]++;//Will give 1 kill to killer and it will be saved inside of his/her account
pInfo[playerid][Deaths]++;
SendDeathMessage(killerid, playerid, reason);
return 1;
}
public OnPlayerModelSelection(playerid, response, listid, modelid)
{
if(listid == vehiclelist)
{
if(response)
{
SendClientMessage(playerid, 0xFF0000FF, "Kendaraan Muncul!");
new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
CreateVehicle(modelid, pos[0] + 2.5, pos[1], pos[2] + 2.5, 0.0, random(128), random(128), -1);
}
else SendClientMessage(playerid, 0xFF0000FF, "Mematalkan Pemilihan Kendaraan");
return 1;
}
if(listid == skinlist)
{
if(response)
{
SendClientMessage(playerid, 0xFF0000FF, "Skin Terganti!");
SetPlayerSkin(playerid, modelid);
}
else SendClientMessage(playerid, 0xFF0000FF, "Membatalkan Pemilihan Skin");
return 1;
}
if(listid == weaponlist)
{
if(modelid==331) //1 knuckle
{
if(GetPlayerMoney(playerid) <450) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Brass Knuckles dengan $450");
GivePlayerMoney(playerid, -450);
GivePlayerWeapon(playerid, 1, 9999);
}
if(modelid==335) //4 pisau
{
if(GetPlayerMoney(playerid) <750) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Knife dengan $750");
GivePlayerMoney(playerid, -750);
GivePlayerWeapon(playerid, 4, 9999);
}
if(modelid==339) //8 katana
{
if(GetPlayerMoney(playerid) <1000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Katana dengan $1000");
GivePlayerMoney(playerid, -1000);
GivePlayerWeapon(playerid, 8, 9999);
}
if(modelid==346) //22 9mm
{
if(GetPlayerMoney(playerid) <3500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Pistol 9mm dengan $3500");
GivePlayerMoney(playerid, -3500);
GivePlayerWeapon(playerid, 22, 350);
}
if(modelid==347) //23 silenced 9mm
{
if(GetPlayerMoney(playerid) <5000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Pistol Silenced 9mm dengan $5000");
GivePlayerMoney(playerid, -5000);
GivePlayerWeapon(playerid, 23, 350);
}
if(modelid==348) //24 Deagle
{
if(GetPlayerMoney(playerid) <8000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Deagle Pistol dengan $8000");
GivePlayerMoney(playerid, -8000);
GivePlayerWeapon(playerid, 24, 200);
}
if(modelid==349) //25 Shotgun
{
if(GetPlayerMoney(playerid) <6000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Shotgun dengan $6000");
GivePlayerMoney(playerid, -6000);
GivePlayerWeapon(playerid, 25, 80);
}
if(modelid==350) //26 Sawnoff Shotgun
{
if(GetPlayerMoney(playerid) <8000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Sawnoff Shotgun dengan $8000");
GivePlayerMoney(playerid, -8000);
GivePlayerWeapon(playerid, 26, 80);
}
if(modelid==351) //27 auto Shotgun
{
if(GetPlayerMoney(playerid) <10000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Combat Shotgun dengan $10000");
GivePlayerMoney(playerid, -10000);
GivePlayerWeapon(playerid, 27, 80);
}
if(modelid==352)
{
if(GetPlayerMoney(playerid) <7500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Uzi dengan $5000");
GivePlayerMoney(playerid, -7500);
GivePlayerWeapon(playerid, 28, 650);
}
if(modelid==356)
{
if(GetPlayerMoney(playerid) <22500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli M4 Maverick dengan $22500");
GivePlayerMoney(playerid, -22500);
GivePlayerWeapon(playerid, 31, 400);
}
if(modelid==357)
{
if(GetPlayerMoney(playerid) <15000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Gun Rifle dengan $15000");
GivePlayerMoney(playerid, -15000);
GivePlayerWeapon(playerid, 33, 50);
}
if(modelid==358)
{
if(GetPlayerMoney(playerid) <17500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Sniper Rifle dengan $17500");
GivePlayerMoney(playerid, -17500);
GivePlayerWeapon(playerid, 34, 40);
}
if(modelid==359)
{
if(GetPlayerMoney(playerid) <100000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli RPG dengan $100000");
GivePlayerMoney(playerid, -100000);
GivePlayerWeapon(playerid, 35, 10);
}
if(modelid==367)
{
if(GetPlayerMoney(playerid) <7500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Canon 1DX dengan $7500");
GivePlayerMoney(playerid, -7500);
GivePlayerWeapon(playerid, 43, 1000);
}
if(modelid==371)
{
if(GetPlayerMoney(playerid) <600) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Parachute dengan $6000");
GivePlayerMoney(playerid, -6000);
GivePlayerWeapon(playerid, 46, 1);
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == register) //If dialog id is a register dialog
{//then
if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
if(response) //if they clicked the first button "Register"
{//then
if(!strlen(inputtext)) //If they didn't enter any password
{// then we will tell to them to enter the password to register
ShowPlayerDialog(playerid,register,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
return 1;
}
//If they have entered a correct password for his/her account...
new hashpass[129]; //Now we will create a new variable to hash his/her password
WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
INI_WriteInt(file,"VIPLevel",0);//As explained above
INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
INI_WriteInt(file,"Kills",0);//As explained above
INI_WriteInt(file,"Deaths",0);//As explained above
INI_Close(file);//Now after we've done saving their data, we now need to close the file
SendClientMessage(playerid,-1,"You have been successfully registered");//Tell to them that they have successfully registered a new account
return 1;
}
}
if(dialogid == login) //If dialog id is a login dialog
{//then
if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
if(response) //if they clicked the first button "Register"
{//then
new hashpass[129]; //Will create a new variable to hash his/her password
WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
{//then
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
}
else //If they've entered an incorrect password
{//then
ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
return 1;
}
}
}
return 1;
}
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_Int("Money",pInfo[playerid][Money]); //As explained above
INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
INI_Int("Weapon1", WeaponInfo[playerid][Weapon1]);
INI_Int("Weapon2", WeaponInfo[playerid][Weapon2]);
INI_Int("Weapon3", WeaponInfo[playerid][Weapon3]);
INI_Int("Weapon4", WeaponInfo[playerid][Weapon4]);
INI_Int("Weapon5", WeaponInfo[playerid][Weapon5]);
INI_Int("Weapon6", WeaponInfo[playerid][Weapon6]);
INI_Int("Weapon7", WeaponInfo[playerid][Weapon7]);
INI_Int("Weapon8", WeaponInfo[playerid][Weapon8]);
INI_Int("Weapon9", WeaponInfo[playerid][Weapon9]);
INI_Int("Weapon10", WeaponInfo[playerid][Weapon10]);
INI_Int("Weapon11", WeaponInfo[playerid][Weapon11]);
INI_Int("Weapon12", WeaponInfo[playerid][Weapon12]);
// Load Ammo
INI_Int("Ammo1", WeaponInfo[playerid][Ammo1]);
INI_Int("Ammo2", WeaponInfo[playerid][Ammo2]);
INI_Int("Ammo3", WeaponInfo[playerid][Ammo3]);
INI_Int("Ammo4", WeaponInfo[playerid][Ammo4]);
INI_Int("Ammo5", WeaponInfo[playerid][Ammo5]);
INI_Int("Ammo6", WeaponInfo[playerid][Ammo6]);
INI_Int("Ammo7", WeaponInfo[playerid][Ammo7]);
INI_Int("Ammo8", WeaponInfo[playerid][Ammo8]);
INI_Int("Ammo9", WeaponInfo[playerid][Ammo9]);
INI_Int("Ammo10", WeaponInfo[playerid][Ammo10]);
INI_Int("Ammo11", WeaponInfo[playerid][Ammo11]);
INI_Int("Ammo12", WeaponInfo[playerid][Ammo12]);
return 1;
}
//Stock Functions
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),UserPath,name);
return str;
}
stock NoMinus(string[])
{
for(new i; i < strlen(string); i++)
{
if(string[i] == '-')
{
strdel(string, i, i+1);
}
}
return string;
}
stock pWeaponSave(playerid)
{
new string[50];
format(string, sizeof(string), PATH, GetName(playerid));
return string;
}
stock GetName(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
public RandomMessage()
{
TextDrawSetString(ShadowsRandom, RandomMessages[random(sizeof(RandomMessages))]);
return 1;
}
//Commands
CMD:weapon(playerid, params[])
{
ShowModelSelectionMenu(playerid, weaponlist, "Weapon:");
return 1;
}
CMD:vehicle(playerid, params[])
{
ShowModelSelectionMenu(playerid, vehiclelist, "Vehicle:");
return 1;
}
CMD:skin(playerid, params[])
{
ShowModelSelectionMenu(playerid, skinlist, "Select Skin:");
return 1;
}
CMD:kill(playerid, params[])
{
SetPlayerHealth(playerid, 0);
return 1;
}
CMD:s(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, posX[playerid], posY[playerid], posZ[playerid]);
GetVehicleZAngle(vehicleid, posA[playerid]);
}
else
{
GetPlayerPos(playerid, posX[playerid], posY[playerid], posZ[playerid]);
GetPlayerFacingAngle(playerid, posA[playerid]);
}
Interior[playerid] = GetPlayerInterior(playerid);
VirtualWorld[playerid] = GetPlayerVirtualWorld(playerid);
SendClientMessage(playerid, -1, "Kamu telah menyimpan posisimu");
SendClientMessage(playerid, -1, "Gunakan /r, /loadpos Untuk memuat posisi yang disimpan!");
Saved[playerid] = 1;
return 1;
}
CMD:savepos(playerid, params[])
{
return cmd_s(playerid, params);
}
CMD:r(playerid, params[])
{
if(Saved[playerid] == 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
SetVehiclePos(vehicleid, posX[playerid], posY[playerid], posZ[playerid]);
SetVehicleZAngle(vehicleid, posA[playerid]);
LinkVehicleToInterior(vehicleid, Interior[playerid]);
SetVehicleVirtualWorld(vehicleid, VirtualWorld[playerid]);
}
else
{
SetPlayerPos(playerid, posX[playerid], posY[playerid], posZ[playerid]);
SetPlayerFacingAngle(playerid, posA[playerid]);
SetPlayerInterior(playerid, Interior[playerid]);
SetPlayerVirtualWorld(playerid, VirtualWorld[playerid]);
}
SendClientMessage(playerid, -1, "Kamu telah memuat posisimu");
SendClientMessage(playerid, -1, "Gunakan /s, /savepos Untuk menyimpan posisi yang disimpan!");
}
else
{
SendClientMessage(playerid, -1, "ERROR: Kamu belum pernah menyimpan posisi sebelumnya!");
SendClientMessage(playerid, -1, "Gunakan /s, /savepos Untuk menyimpan posisi yang disimpan");
}
return 1;
}
CMD:loadpos(playerid, params[])
{
return cmd_r(playerid, params);
}
CMD:v(playerid, params[])
{
return cmd_v(playerid, params);
}
CMD:w(playerid, params[])
{
return cmd_w(playerid, params);
}
Re: Need Little help with Y_Ini For my GameMode -
DheWardhana - 06.11.2013
here is the problem

Код:
public OnPlayerDisconnect(playerid, reason)
{
GetPlayerWeaponData(playerid, 1, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
GetPlayerWeaponData(playerid, 2, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
GetPlayerWeaponData(playerid, 3, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
GetPlayerWeaponData(playerid, 4, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
GetPlayerWeaponData(playerid, 5, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
GetPlayerWeaponData(playerid, 6, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
GetPlayerWeaponData(playerid, 7, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
GetPlayerWeaponData(playerid, 8, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
GetPlayerWeaponData(playerid, 9, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
GetPlayerWeaponData(playerid, 10, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
GetPlayerWeaponData(playerid, 11, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
GetPlayerWeaponData(playerid, 12, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);
if(fexist(pWeaponSave(playerid)))
new INI:file = INI_Open(pWeaponSave(playerid));
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
// Weapon Save
INI_WriteInt(file, "Weapon1", WeaponInfo[playerid][Weapon1]);
INI_WriteInt(file, "Weapon2", WeaponInfo[playerid][Weapon2]);
INI_WriteInt(file, "Weapon3", WeaponInfo[playerid][Weapon3]);
INI_WriteInt(file, "Weapon4", WeaponInfo[playerid][Weapon4]);
INI_WriteInt(file, "Weapon5", WeaponInfo[playerid][Weapon5]);
INI_WriteInt(file, "Weapon6", WeaponInfo[playerid][Weapon6]);
INI_WriteInt(file, "Weapon7", WeaponInfo[playerid][Weapon7]);
INI_WriteInt(file, "Weapon8", WeaponInfo[playerid][Weapon8]);
INI_WriteInt(file, "Weapon9", WeaponInfo[playerid][Weapon9]);
INI_WriteInt(file, "Weapon10", WeaponInfo[playerid][Weapon10]);
INI_WriteInt(file, "Weapon11", WeaponInfo[playerid][Weapon11]);
INI_WriteInt(file, "Weapon12", WeaponInfo[playerid][Weapon12]);
// Ammo Save
INI_WriteInt(file, "Ammo1", WeaponInfo[playerid][Ammo1]);
INI_WriteInt(file, "Ammo2", WeaponInfo[playerid][Ammo2]);
INI_WriteInt(file, "Ammo3", WeaponInfo[playerid][Ammo3]);
INI_WriteInt(file, "Ammo4", WeaponInfo[playerid][Ammo4]);
INI_WriteInt(file, "Ammo5", WeaponInfo[playerid][Ammo5]);
INI_WriteInt(file, "Ammo6", WeaponInfo[playerid][Ammo6]);
INI_WriteInt(file, "Ammo7", WeaponInfo[playerid][Ammo7]);
INI_WriteInt(file, "Ammo8", WeaponInfo[playerid][Ammo8]);
INI_WriteInt(file, "Ammo9", WeaponInfo[playerid][Ammo9]);
INI_WriteInt(file, "Ammo10", WeaponInfo[playerid][Ammo10]);
INI_WriteInt(file, "Ammo11", WeaponInfo[playerid][Ammo11]);
INI_WriteInt(file, "Ammo12", WeaponInfo[playerid][Ammo12]);
INI_Close(file);
}
return 1;
}
and this the error output..
Код:
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn-upgrade.pwn(366) : error 003: declaration of a local variable must appear in a compound block
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn-upgrade.pwn(366) : warning 221: label name "INI" shadows tag name
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn-upgrade.pwn(366) : error 017: undefined symbol "file"
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn-upgrade.pwn(366) : warning 203: symbol is never used: "INI"
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn-upgrade.pwn(366 -- 403) : error 010: invalid function or declaration
D:\Work\samp03x_svr_R2_win32\gamemodes\stpn-upgrade.pwn(366 -- 403) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: Need Little help with Y_Ini For my GameMode -
Uberanwar - 06.11.2013
Which code does it comes from (366 -- 403)?
Re: Need Little help with Y_Ini For my GameMode -
DheWardhana - 06.11.2013
FIXED!

Thanks to Scrillex..