Repair command with money -
luckie12 - 30.03.2016
I tried to create a repair command:
pawn Код:
CMD:repairv(playerid)
{
if(PInfo[playerid][Money] < 2500) return SendClientMessage(playerid, COLOR_RED, "You dont have enough money! ($2500)");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle!");
RepairVehicle(GetPlayerVehicleID(playerid));
GivePlayerMoney(playerid,PInfo[playerid][Money]-2500);
SendClientMessage(playerid, COLOR_LIGHTGREEN,"You repaired the vehicle (-$2500)");
return 1;
}
This has to check for the Money of the player, if its less then 2500 return a message,
If its enough AND hes in a vehicle, repair the vehicle he is in and give the player -2500 money ...
Re: Repair command with money -
Mencent - 30.03.2016
Hi!
Do it like this:
PHP код:
CMD:repairv(playerid)
{
if(PInfo[playerid][Money] < 2500) return SendClientMessage(playerid, COLOR_RED, "You dont have enough money! ($2500)");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle!");
RepairVehicle(GetPlayerVehicleID(playerid));
GivePlayerMoney(playerid,-2500);
PInfo[playerid][Money] -= 2500;
SendClientMessage(playerid, COLOR_LIGHTGREEN,"You repaired the vehicle (-$2500)");
return 1;
}
Re: Repair command with money -
luckie12 - 30.03.2016
allright
And theres ONE more problem, everytime someone logs in, the money is being set back to 5000, most of the time the player doesnt even get the money added
My login:
pawn Код:
CMD:login(playerid,params[])
{
print("Code pos #6");
new file[256],n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"gAdmin/Users/%s.txt",n);
if(!dini_Exists(file)) return SendClientMessage(playerid,COLOR_YELLOW,"You are not registered! Please /register");
if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are already logged in!");
if(PInfo[playerid][Regged] == 0) return SendClientMessage(playerid,COLOR_ORANGE,"You are not registered! Please /register");
if(strlen(params))
{
if(dini_Exists(file))
{
print("Code pos #7");
if(strcmp(params,dini_Get(file,"Password"),false) != 0)
{
SendClientMessage(playerid,COLOR_YELLOW,"Wrong Password!");
}
else
{
dini_IntSet(file,"Logged",1);
PInfo[playerid][Logged] = 1;
PInfo[playerid][Level] = dini_Int(file,"Level");
PInfo[playerid][Team] = dini_Int(file, "Team");
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PInfo[playerid][Money]);
SendClientMessage(playerid,COLOR_YELLOW,"You have now logged in!");
return 1;
}
}
}
else
{
SendClientMessage(playerid,COLOR_GREY,"USAGE: /login <Password>");
return 1;
}
return 1;
}
As u can see i use:
Код:
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PInfo[playerid][Money]);
and my register has this:
Код:
dini_IntSet(file,"Money",5000);
Re: Repair command with money -
theonethatownz - 30.03.2016
I dont see you getting the money value from the player.
Re: Repair command with money -
luckie12 - 30.03.2016
Код:
GivePlayerMoney(playerid, PInfo[playerid][Money]);
at the login section
Re: Repair command with money -
Mencent - 30.03.2016
PHP код:
CMD:login(playerid,params[])
{
print("Code pos #6");
new file[256],n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"gAdmin/Users/%s.txt",n);
if(!dini_Exists(file)) return SendClientMessage(playerid,COLOR_YELLOW,"You are not registered! Please /register");
if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are already logged in!");
if(PInfo[playerid][Regged] == 0) return SendClientMessage(playerid,COLOR_ORANGE,"You are not registered! Please /register");
if(strlen(params))
{
if(dini_Exists(file))
{
print("Code pos #7");
if(strcmp(params,dini_Get(file,"Password"),false) != 0)
{
SendClientMessage(playerid,COLOR_YELLOW,"Wrong Password!");
}
else
{
dini_IntSet(file,"Logged",1);
PInfo[playerid][Logged] = 1;
PInfo[playerid][Level] = dini_Int(file,"Level");
PInfo[playerid][Team] = dini_Int(file, "Team");
PInfo[playerid][Money] = dini_Int(file,"Money");
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PInfo[playerid][Money]);
SendClientMessage(playerid,COLOR_YELLOW,"You have now logged in!");
return 1;
}
}
}
else
{
SendClientMessage(playerid,COLOR_GREY,"USAGE: /login <Password>");
return 1;
}
return 1;
}
Re: Repair command with money -
luckie12 - 30.03.2016
EDIT: im stupid, had a typo
Re: Repair command with money -
Mencent - 30.03.2016
Each person can do a mistake so nobody is stupid.
Does it work?
Re: Repair command with money -
luckie12 - 30.03.2016
When i use the repair command, the money gets withdrawn, but not in the File, when i login i still have 5000
Re: Repair command with money -
Mencent - 30.03.2016
Do you save your money? Show us the code.