Passport Bug! -
Oscii - 25.05.2012
Hello.
i was testing this command with my freind and when i /givepassport anyonesid!
it changes their name to ' . '
Or just blank
Screen:
pawn Код:
if(strcmp(cmd, "/givepassport", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsACop(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not a Cop !");
return 1;
}
if(PlayerInfo[playerid][pRank] >= 4)
{
if(PlayerInfo[playerid][pDBanned] == 1)
{
SendClientMessage(playerid, COLOR_CREAM, "You are banned from cop duty.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_CREAM, "USAGE: /givepassport [playerid]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, sendername, sizeof(sendername));
if(PlayerInfo[giveplayerid][pPassport] == 1) return SendClientMessage(playerid, COLOR_GREY, "This player has a passport already!");
PlayerInfo[giveplayerid][pPassport] = 1;
format(string, sizeof(string),"You gave a passport to %s.",giveplayer);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string),"%s gave you a passport. You are now a citizen..",giveplayer);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string),"[ADMIN]: %s gave a passport to %s.",sendername, giveplayer);
SendAdminMessage(COLOR_LIGHTRED, string);
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /givepassport %s",d,m,y,h,mi,s,giveplayer, sendername);
AdminLog(string);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is Offline !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You need to be rank 4 or above.");
return 1;
}
}
return 1;
}
Re: Passport Bug! -
milanosie - 25.05.2012
format(string, sizeof(string),"[ADMIN]: %s gave a passport to %s.",sendername, giveplayer);
Giveplayer is an integer, not a string.
Get the name of giveplayer before using it in a %s AKA string
Re: Passport Bug! -
Oscii - 25.05.2012
So.. what should the code be then..?
Im confused on this part..
Re: Passport Bug! -
milanosie - 25.05.2012
new name2[24];
GetPlayerName(giveplayer, name2, 24);
format(string, sizeof(string),"[ADMIN]: %s gave a passport to %s.",sendername,name2);
Re: Passport Bug! -
Oscii - 25.05.2012
pawn Код:
error 003: declaration of a local variable must appear in a compound block
warning 217: loose indentation
error 017: undefined symbol "name2"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 107: too many error messages on one line
Now i get these..
Current Code with updated things is:
pawn Код:
if(strcmp(cmd, "/givepassport", true) == 0)
new name2[24];
GetPlayerName(giveplayer, name2, 24);
{
if(IsPlayerConnected(playerid))
{
if(!IsACop(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not a Cop !");
return 1;
}
if(PlayerInfo[playerid][pRank] >= 4)
{
if(PlayerInfo[playerid][pDBanned] == 1)
{
SendClientMessage(playerid, COLOR_CREAM, "You are banned from cop duty.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_CREAM, "USAGE: /givepassport [playerid]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, sendername, sizeof(sendername));
if(PlayerInfo[giveplayerid][pPassport] == 1) return SendClientMessage(playerid, COLOR_GREY, "This player has a passport already!");
PlayerInfo[giveplayerid][pPassport] = 1;
format(string, sizeof(string),"You gave a passport to %s.",giveplayer);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string),"%s gave you a passport. You are now a citizen..",sendername);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string),"[ADMIN]: %s gave a passport to %s.",sendername,name2);
SendAdminMessage(COLOR_LIGHTRED, string);
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /givepassport %s",d,m,y,h,mi,s,giveplayer, sendername);
AdminLog(string);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is Offline !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You need to be rank 4 or above.");
return 1;
}
}
return 1;
}
Re: Passport Bug! -
milanosie - 25.05.2012
Post the code I gave you UNDER giveplayer = Returnid etc.,
after you defined giveplayer
AW: Passport Bug! -
EthanR - 25.05.2012
Код:
if(strcmp(cmd, "/givepassport", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new name2[24];
GetPlayerName(giveplayer, name2, 24);
if(!IsACop(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not a Cop !");
return 1;
}
if(PlayerInfo[playerid][pRank] >= 4)
{
if(PlayerInfo[playerid][pDBanned] == 1)
{
SendClientMessage(playerid, COLOR_CREAM, "You are banned from cop duty.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_CREAM, "USAGE: /givepassport [playerid]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, sendername, sizeof(sendername));
if(PlayerInfo[giveplayerid][pPassport] == 1) return SendClientMessage(playerid, COLOR_GREY, "This player has a passport already!");
PlayerInfo[giveplayerid][pPassport] = 1;
format(string, sizeof(string),"You gave a passport to %s.",giveplayer);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string),"%s gave you a passport. You are now a citizen..",sendername);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string),"[ADMIN]: %s gave a passport to %s.",sendername,name2);
SendAdminMessage(COLOR_LIGHTRED, string);
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /givepassport %s",d,m,y,h,mi,s,giveplayer, sendername);
AdminLog(string);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is Offline !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You need to be rank 4 or above.");
return 1;
}
}
return 1;
}
Re: Passport Bug! -
Oscii - 25.05.2012
I have added that code but i just have one error and one warning now..
Error on
pawn Код:
GetPlayerName(giveplayer, name2, 24);
error 035: argument type mismatch (argument 1)
2 lose indications!
warning 217: loose indentation
Re: Passport Bug! -
milanosie - 25.05.2012
use giveplayerid instead of giveplayer
And the loos indentation is a wrongfulyl TAB, nothing serious
Re: Passport Bug! -
MadeMan - 25.05.2012
pawn Код:
if(PlayerInfo[giveplayerid][pPassport] == 1) return SendClientMessage(playerid, COLOR_GREY, "This player has a passport already!");
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
PlayerInfo[giveplayerid][pPassport] = 1;
format(string, sizeof(string),"You gave a passport to %s.",giveplayer);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string),"%s gave you a passport. You are now a citizen..",sendername);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string),"[ADMIN]: %s gave a passport to %s.",sendername, giveplayer);
SendAdminMessage(COLOR_LIGHTRED, string);
You don't need the 'name2' variable.
Re: Passport Bug! -
Oscii - 25.05.2012
FIXED!
Thank you very much milanosie!!
+1 rep!
Thank you to all the others who helped me also!
EDIT:
I rep'd everyone that helped.