I need some help! -
RaFsTar - 20.07.2009
Код:
forward Jail(playerid, time);
forward jailcount(time);
//Jail
//==============================================================================
new JailCount = -1;
public Jail(playerid, time)
{
if(JailCount == -1)
{
JailCount = time;
SetTimer("jailcount",5000,0);
}
}
public jailcount(time)
{
new string[128];
JailCount--;
if(JailCount==0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GameTextForPlayer(i,"~g~You are Free to go~ r~!",1000,6);
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
SetPlayerPos(i,267.9442,77.4124,1001.0391);
SendClientMessage(i,COLOR_GREEN,"[ ! ] Jail time is over !");
SendClientMessage(i,COLOR_GREEN,"[ ! ] You are free to go !");
}
return 0;
}
else
{
new text[7]; format(text,sizeof(text),"~w~%d",JailCount);
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
GameTextForPlayer(i,text,1000,6);
SendClientMessage(i,COLOR_RED,"[ ! ] You Are In Jail !");
SetPlayerInterior(i, 6);
SetPlayerPos(i,265.0813,77.5967,1001.0391);
format(string,sizeof(string), "[ ! ] You are jailed for: %d sec. ! ",JailCount);
SendClientMessage(i, COLOR_LIGHTRED, string);
}
}
SetTimer("jailcount",1000,0);
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
// JAIL
if (strcmp(cmd,"/ajail", true,5) == 0)
{
if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: /ajail »[playerid]« [time]");
id = strval(tmp);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_LIGHTRED, "[ ! ] That player isn't active.");
new time = strval(tmp);
if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: /ajail [playerid] »[time]«");
Jail(id,time);
GetPlayerName(playerid, Aname, sizeof(Aname));
GetPlayerName(playerid, Idname, sizeof(Idname));
format(string,sizeof(string), "[ ! ] You have been jailed by %s for %d sec ! ",Aname,time);
SendClientMessage(id,COLOR_LIGHTRED, string);
format(string,sizeof(string), "[ ! ] You have jailed %s for %d sec ! ",id,time);
SendClientMessage(playerid,COLOR_LIGHTRED, string);
}
}
Well i need help for 2 things.
When I try to jail someone, it's suppose to be "/ajail id time", I only can put the id because it does not identifies the variable "time". I can say that I don't know who to make a command that uses 2 variables.
The second problem is when I jail a player, all current online players are jailed
I am new on this pawn scripting, I wish some help from the experience people.
Best Regards,
Joгo Assunзгo.
PS: If i didn't post in the right section, i am sorry for that !
Re: I need some help! -
James_Alex - 20.07.2009
first change the "SetTimer("jailcount",5000,0);" by "SetTimerEx("jailcount",5000,0, "i", playerid);"
second change the "public JailCount(time)" by public JailCount(playerid, time)"
and try
pawn Код:
if (strcmp(cmd,"/ajail", true,5) == 0)
{
tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, thecolor, "USAGE: bla bla"); return 1; }
id = strval(tmp);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_LIGHTRED, "[ ! ] That player isn't active.");
new time = strval(tmp);
{
tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, thecolor, "USAGE: bla bla"); return 1; }
Jail(id,time);
GetPlayerName(playerid, Aname, sizeof(Aname));
GetPlayerName(playerid, Idname, sizeof(Idname));
format(string,sizeof(string), "[ ! ] You have been jailed by %s for %d sec ! ",Aname,time);
SendClientMessage(id,COLOR_LIGHTRED, string);
format(string,sizeof(string), "[ ! ] You have jailed %s for %d sec ! ",id,time);
SendClientMessage(playerid,COLOR_LIGHTRED, string);
}
Re: I need some help! -
RaFsTar - 20.07.2009
Код:
#define CITIZEN 1
#define COP 2
#define SWAT 3
#define MAYOR 4
#define CITIZEN_COLOR 0xFFFFFFFF
#define COP_COLOR 0x33CCFFAA
#define SWAT_COLOR 0x0000BBAA
#define MAYOR_COLOR 0x9900BEFF
//=====================================================
public OnPlayerDisconnect(playerid, reason)
{
if (Logged[playerid]) {
dUserSetINT(PlayerName(playerid)).("Money",GetPlayerMoney(playerid));
dUserSetINT(PlayerName(playerid)).("Rcash",GetPlayerRcash(playerid));
dUserSetINT(PlayerName(playerid)).("Admin",GetPlayerAdminLvl(playerid));
dUserSetINT(PlayerName(playerid)).("Job",GetPlayerJob(playerid));
}
if (Logged[playerid]) {
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
dUserSetINT(PlayerName(playerid)).("x",floatround(x));
dUserSetINT(PlayerName(playerid)).("y",floatround(y));
dUserSetINT(PlayerName(playerid)).("z",floatround(z));
}
return false;
}
//=====================================================
public OnPlayerRequestClass(playerid, classid)
{
SetupPlayerForClassSelection(playerid);
if (Logged[playerid])
{
if(gTeam[playerid]==CITIZEN)
{
if(GetPlayerJob(playerid) == CITIZEN)
{
GameTextForPlayer(playerid,"~w~CITIZEN~n~~n~~n~~g~Available for you]",1000,5);
return 1;
}
else
{
GameTextForPlayer(playerid,"~w~CITIZEN~n~~n~~n~~r~Not available for you]",1000,5);
}
return 0;
}
if(gTeam[playerid]==COP)
{
if(GetPlayerJob(playerid) == COP)
{
GameTextForPlayer(playerid,"~b~POLICE COP~n~~n~~n~~g~Available for you]",1000,5);
return 1;
}
else
{
GameTextForPlayer(playerid,"~b~POLICE COP~n~~n~~n~~r~Not available for you]",1000,5);
}
return 0;
}
if(gTeam[playerid]==SWAT)
{
if(GetPlayerJob(playerid) == SWAT)
{
GameTextForPlayer(playerid,"~b~SWAT~n~~n~~n~~g~Available for you]",1000,5);
return 1;
}
else
{
GameTextForPlayer(playerid,"~b~SWAT~n~~n~~n~~r~Not available for you]",1000,5);
}
return 0;
}
if(gTeam[playerid]==MAYOR)
{
if(GetPlayerJob(playerid) == MAYOR)
{
GameTextForPlayer(playerid,"~p~MAYOR~n~~n~~n~~g~Available for you]",1000,5);
return 1;
}
else
{
GameTextForPlayer(playerid,"~p~MAYOR~n~~n~~n~~r~Not available for you]",1000,5);
}
return 0;
}
return 1;
}
return 1;
}
//==============================================================================
public OnPlayerRequestSpawn(playerid)
{
new tmp[50];
if(gTeam[playerid]==CITIZEN)
{
if(GetPlayerJob(playerid) == CITIZEN)
{
format(tmp,sizeof(tmp),"[ ! ] Welcome to Citizen: %s",Name(playerid));
SendClientMessageToAll(CITIZEN_COLOR,tmp);
SendClientMessage(playerid,COLOR_YELLOW,"[ ! ] This is real life mod, don't kill everybody for no reason");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_RED,"You are not a citizen!");
}
return 0;
}
if(gTeam[playerid]==COP)
{
if(GetPlayerJob(playerid) == COP)
{
format(tmp,sizeof(tmp),"[ ! ] Welcome to Police Officer: %s",Name(playerid));
SendClientMessageToAll(COP_COLOR,tmp);
SendClientMessage(playerid,COLOR_YELLOW,"[ ! ] This is real life mod, don't kill everybody for no reason");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_RED,"You are not a cop!");
}
return 0;
}
if(gTeam[playerid]==SWAT)
{
if(GetPlayerJob(playerid) == SWAT)
{
format(tmp,sizeof(tmp),"[ ! ] Welcome to S.W.A.T. Force: %s",Name(playerid));
SendClientMessageToAll(MAYOR_COLOR,tmp);
SendClientMessage(playerid,COLOR_YELLOW,"[ ! ] This is real life mod, don't kill everybody for no reason");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_RED,"You are not a S.W.A.T. member!");
}
return 0;
}
if(gTeam[playerid]==MAYOR)
{
if(GetPlayerJob(playerid) == MAYOR)
{
format(tmp,sizeof(tmp),"[ ! ] Welcome to Mayor: %s",Name(playerid));
SendClientMessageToAll(MAYOR_COLOR,tmp);
SendClientMessage(playerid,COLOR_YELLOW,"[ ! ] This is real life mod, don't kill everybody for no reason");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_RED,"You are not a mayor!");
}
return 0;
}
if(Logged[playerid] == 0)
{
SendClientMessage(playerid,COLOR_LIGHTFLASHRED,"[ ! ] You need to login before you spawn ! Use '/login [password]' !");
return 0;
}
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
When I am on the classes it appears only my current job "COP" and I can join at other classes .. I don't know what is bugged here ..
Re: I need some help! -
MadeMan - 20.07.2009
You can stop player from spawning only OnPlayerRequestSpawn by return 0; but you should have return 1 in OnPlayerRequestClass