PDA

View Full Version : /goto problem.


ChristolisTV
31/07/2015, 07:55 PM
Hello again!

I am creating my own admin filterscript with MySQL sscanf and zcmd.

My problem:
Check out this code:
CMD:goto(playerid,params[]){
new id,str[256],name[MAX_PLAYER_NAME];
if(sscanf(params,"i",id))return SendClientMessage(playerid,-1,"{FF9900}Usage:{FFFFFF} /goto [Playerid]");
if(!IsConnect(id))return SendClientMessage(playerid,-1,"Player{FF0000} not{FFFFFF} found");
if(IsPlayerInDMgoto[playerid] != 0) return SendClientMessage(playerid, -1, "{FFFFFF}You{FF0000} can't{FFFFFF} goto this player while on DM!");
if(P_DATA[id][Agoto] == false)return SendClientMessage(playerid,-1,"{FFFFFF}You{FF0000} can't{FFFFFF} goto to this player because he disabled it.");
new Float:Pos[4];
GetPlayerPos(id,Pos[0],Pos[1],Pos[2]);
GetPlayerFacingAngle(id,Pos[3]);
if(IsPlayerInAnyVehicle(playerid)){
SetVehiclePos(GetPlayerVehicleID(playerid),Pos[0],Pos[1],Pos[2]);
}
else{
SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
SetPlayerFacingAngle(playerid,Pos[3]);
}
GetPlayerName(id,name,sizeof(name));
format(str,sizeof(str),"You have teleported to '{FFFF00}%s{FFFFFF}'.",name);
SendClientMessage(playerid,-1,str);
return 1;
}

When I type /goto 0 it shows me again this: Usage: /goto [Playerid]
Please can you help me fast? +1 Rep if someone helps.

x3378
31/07/2015, 08:09 PM
At a glance the command seems to be fine, but try with this command :).


CMD:goto(playerid, params[])
{
new targetid = INVALID_PLAYER_ID;
if (sscanf(params, "u", targetid))
return SendClientMessage(playerid,-1,"{FF9900}Usage:{FFFFFF} /goto [Playerid]");

if (IsPlayerConnected(targetid) && targetid != INVALID_PLAYER_ID)
{
if (IsPlayerInDMgoto[playerid])
return SendClientMessage(playerid, -1, "{FFFFFF}You{FF0000} can't{FFFFFF} goto this player while on DM!");

if (!P_DATA[targetid][Agoto])
return SendClientMessage(playerid, -1, "{FFFFFF}You{FF0000} can't{FFFFFF} goto to this player because he disabled it.");

new Float:pos[4];
GetPlayerFacingAngle(targetid, pos[3]);
GetPlayerPos(targetid, pos[0], pos[1], pos[2]);

if (IsPlayerInAnyVehicle(playerid)){
SetVehiclePos(GetPlayerVehicleID(playerid), pos[0], pos[1], pos[2]);
}
else{
SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
SetPlayerFacingAngle(playerid, pos[3]);
}
new str[67], name[MAX_PLAYER_NAME];
GetPlayerName(targetid, name, sizeof(name));
format(str, sizeof(str), "You have teleported to '{FFFF00}%s{FFFFFF}'.", name);
SendClientMessage(playerid, -1, str);
}
else SendClientMessage(playerid,-1,"Player{FF0000} not{FFFFFF} found");
return 1;
}

ChristolisTV
31/07/2015, 08:14 PM
At a glance the command seems to be fine, but try with this command :).


CMD:goto(playerid, params[])
{
new targetid = INVALID_PLAYER_ID;
if (sscanf(params, "u", targetid))
return SendClientMessage(playerid,-1,"{FF9900}Usage:{FFFFFF} /goto [Playerid]");

if (IsPlayerConnected(targetid) && targetid != INVALID_PLAYER_ID)
{
if (IsPlayerInDMgoto[playerid])
return SendClientMessage(playerid, -1, "{FFFFFF}You{FF0000} can't{FFFFFF} goto this player while on DM!");

if (!P_DATA[targetid][Agoto])
return SendClientMessage(playerid, -1, "{FFFFFF}You{FF0000} can't{FFFFFF} goto to this player because he disabled it.");

new Float:pos[4];
GetPlayerFacingAngle(targetid, pos[3]);
GetPlayerPos(targetid, pos[0], pos[1], pos[2]);

if (IsPlayerInAnyVehicle(playerid)){
SetVehiclePos(GetPlayerVehicleID(playerid), pos[0], pos[1], pos[2]);
}
else{
SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
SetPlayerFacingAngle(playerid, pos[3]);
}
new str[67], name[MAX_PLAYER_NAME];
GetPlayerName(targetid, name, sizeof(name));
format(str, sizeof(str), "You have teleported to '{FFFF00}%s{FFFFFF}'.", name);
SendClientMessage(playerid, -1, str);
}
else SendClientMessage(playerid,-1,"Player{FF0000} not{FFFFFF} found");
return 1;
}
Sorry mate. Tested but not working. :(

SFA7X
31/07/2015, 08:15 PM
It should work now.
CMD:goto(playerid,params[])
{
new id,str[128],name[MAX_PLAYER_NAME];

if(sscanf(params,"u",id))
{
SendClientMessage(playerid,-1,"{CACA00}[INFO]{FFFFFF}: /goto (Player Name/ID)");
return 1;
}
if(!IsConnect(id))
{
SendClientMessage(playerid,-1,"Player{FF0000} not{FFFFFF} found");
return 1;
}
if(IsPlayerInDMgoto[playerid] != 0)
{
SendClientMessage(playerid, -1, "{FFFFFF}You{FF0000} can't{FFFFFF} goto this player while on DM!");
return 1;
}
if(P_DATA[id][Agoto] == false)
{
SendClientMessage(playerid,-1,"{FFFFFF}You{FF0000} can't{FFFFFF} goto to this player because he disabled it.");
return 1;
}
new Float:Pos[4];
GetPlayerPos(id,Pos[0],Pos[1],Pos[2]);
GetPlayerFacingAngle(id,Pos[3]);
if(IsPlayerInAnyVehicle(playerid)){
SetVehiclePos(GetPlayerVehicleID(playerid),Pos[0],Pos[1],Pos[2]);
}
else{
SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
SetPlayerFacingAngle(playerid,Pos[3]);
}
GetPlayerName(id,name,sizeof(name));
format(str,sizeof(str),"You have teleported to '{FFFF00}%s{FFFFFF}'.",name);
SendClientMessage(playerid,-1,str);
return 1;
}

ChristolisTV
31/07/2015, 08:27 PM
It should work now.
CMD:goto(playerid,params[])
{
new id,str[128],name[MAX_PLAYER_NAME];

if(sscanf(params,"u",id))
{
SendClientMessage(playerid,-1,"{CACA00}[INFO]{FFFFFF}: /goto (Player Name/ID)");
return 1;
}
if(!IsConnect(id))
{
SendClientMessage(playerid,-1,"Player{FF0000} not{FFFFFF} found");
return 1;
}
if(IsPlayerInDMgoto[playerid] != 0)
{
SendClientMessage(playerid, -1, "{FFFFFF}You{FF0000} can't{FFFFFF} goto this player while on DM!");
return 1;
}
if(P_DATA[id][Agoto] == false)
{
SendClientMessage(playerid,-1,"{FFFFFF}You{FF0000} can't{FFFFFF} goto to this player because he disabled it.");
return 1;
}
new Float:Pos[4];
GetPlayerPos(id,Pos[0],Pos[1],Pos[2]);
GetPlayerFacingAngle(id,Pos[3]);
if(IsPlayerInAnyVehicle(playerid)){
SetVehiclePos(GetPlayerVehicleID(playerid),Pos[0],Pos[1],Pos[2]);
}
else{
SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
SetPlayerFacingAngle(playerid,Pos[3]);
}
GetPlayerName(id,name,sizeof(name));
format(str,sizeof(str),"You have teleported to '{FFFF00}%s{FFFFFF}'.",name);
SendClientMessage(playerid,-1,str);
return 1;
}

Unfortunately it isn't working. :'(

Abagail
31/07/2015, 08:32 PM
Try updating sscanf.

ChristolisTV
31/07/2015, 08:38 PM
Try updating sscanf.

Thanks! Solved my problem! +1 Rep of course! 8)

ChristolisTV
31/07/2015, 08:57 PM
Oh god! I can't either do the /setalltime command! And the /setadmin command. Any help please?

NOTE: I changed permissions to 777 but I can't change it now.

Macronix
31/07/2015, 09:00 PM
Show us your code :D

ChristolisTV
31/07/2015, 09:03 PM
Show us your code :D

/setalltime
CMD:setalltime(playerid,params[]){
new time,str[256],name[MAX_PLAYER_NAME];
if(P_DATA[playerid][alevel] < 2)return SendClientMessage(playerid,-1,"{FFFFFF}You must be{FF0000} Level 2{FFFFFF} to use this command.");
if(sscanf(params,"i",time))return SendClientMessage(playerid,-1,"Usage:/setalltime [Time Value]");
if(time < 0 || time > 24)return SendClientMessage(playerid,-1,"Invalid time value");
for(new p=0; p<MAX_PLAYERS; p++){
if(IsConnect(p)){
SetPlayerTime(p,time,0);
}
}
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),"Admin/mod %s has changed time to %d",name,time);
SendClientMessageToAll(-1,str);
return 1;
}

/setadmin
CMD:setadmin(playerid,params[]){
new id,level,str[256],name[MAX_PLAYER_NAME];
if(P_DATA[playerid][alevel] < 4 && !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"{FFFFFF}You must be{FF0000} Level 4{FFFFFF} to use this command!");
if(sscanf(params,"ii",id,level))return SendClientMessage(playerid,0xF6BB0AA,"{FF9900}Usage:{FFFFFF} /setadmin [Playerid] [Level]");
if(!IsConnect(id))return SendClientMessage(playerid,-1,"Player{FF0000} not{FFFFFF} found!");
if(level < 0 || level > 4)return SendClientMessage(playerid,-1,"{FF0000}Invaild{FFFFFF} level!");
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),"{FFFFFF}Administrator{FFFF00} %s{FFFFFF} has changed your level to{FFFF00} %d{FFFFFF}!",name,level);
SendClientMessage(id,-1,str);
P_DATA[id][alevel] = level;
return 1;
}

Variable™
31/07/2015, 09:05 PM
Removed.

025Tadija
31/07/2015, 11:25 PM
If you using sscanf to set something on player use "u" instead of "i", http://prntscr.com/7zernf

if(sscanf(params,"ui", id, level))