30.12.2016, 19:43
Hello dear, i were testing a very simple VIP System and it goes compiled no Errors no mistakes nothing wrong all thing fine.
But when i go ingame to test it look what happened:
Here's code:
But when i go ingame to test it look what happened:
Here's code:
PHP код:
#define FILTERSCRIPT
//Credits to samp
#include <a_samp>
//Credits to Zeex for zcmd
#include <zcmd>
//Credits to ****** for foreach
#include <foreach>
//Credits to ****** for sscanf
#include <sscanf>
#include <dini>
//Credits to me folor colors
#define COLOR_RED 0xF00F00
#define COLOR_GREEN 0xFF000FFF
#define MAX_VIP 3
#define PlayerFile "Vip/%s.ini"
#pragma tabsize 0
enum dData
{
Vip
}
new PlayerInfo[MAX_PLAYERS][dData];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("Vip system loaded!");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
new file[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),PlayerFile,name);
if(!dini_Exists(file) )
{
dini_Create(file);
dini_Set(file,"Name",name);
dini_IntSet(file,"Vip",0);
PlayerInfo[playerid][Vip] = 0;
SendClientMessage(playerid,COLOR_RED,"Your vip level is 0; !");
}
else
{
PlayerInfo[playerid][Vip] = dini_Int(file,"Vip");
new string[256];
format(string,sizeof(string),"Your vip level is %d",PlayerInfo[playerid][Vip]);
SendClientMessage(playerid,COLOR_GREEN,string);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new file[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),PlayerFile,name);
if(dini_Exists(file) )
{
dini_IntSet(file,"Vip",PlayerInfo[playerid][Vip]);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
if(text[0] == '!' )
{
if(PlayerInfo[playerid][Vip] > 0)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new string[256];
format(string,sizeof(string),"Vip -- %s ( rank: %d): %s",name,PlayerInfo[playerid][Vip],text[0]);
MessageToVips(COLOR_GREEN,string);
return 0;
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
return 0;
}
CMD:setvip(playerid,params[])
{
new id, level;
if(sscanf(params,"ud",id,level) ) return SendClientMessage(playerid,COLOR_RED,"USUAGE: /setvip [id][ level]");
if(!IsPlayerAdmin(playerid) ) return SendClientMessage(playerid,COLOR_RED,"You are not an admin!");
if(level > MAX_VIP) return SendClientMessage(playerid,COLOR_RED,"Invalid Level");
if(!IsPlayerConnected(id) ) return SendClientMessage(playerid,COLOR_RED,"Player is not connected");
else
{
new name[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
GetPlayerName(id,playername,sizeof(playername));
new fstring[256], zstring[256];
format(fstring,sizeof(fstring),"Administrator %s maked you V.I.P level %d",name,level);
format(zstring,sizeof(zstring),"You maked %s level %d",playername,level);
SendClientMessage(playerid,COLOR_RED,zstring);
SendClientMessage(id,COLOR_RED,fstring);
PlayerInfo[id][Vip] = level;
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
//mesage to vips
stock MessageToVips(color, const string[])
{
foreach(Player,i)
{
if(IsPlayerConnected(i) == 1)
if(PlayerInfo[i][Vip] >= 1)
SendClientMessage(i,color,string);
}
}