setting player cash -
Stu1 - 03.11.2012
I require assistance again
I have this
PHP код:
CMD:fixveh(playerid, params[])
{
new vehicleid;
vehicleid = GetClosestVehiclePolice(playerid);
for (new checkvehicle; checkvehicle < MAX_PLAYERS; checkvehicle++)
if(IsPlayerInVehicle(checkvehicle, vehicleid))
{
if(gTeam[playerid] == ASSISTANCE) // Learn how to use if statements
{
ShowPlayerDialog(checkvehicle, FIX_D, DIALOG_STYLE_MSGBOX, "Repair", "Would you like your vehicle repaired?", "Yes", "No");
SendClientMessage(playerid, -1,"Repair request sent!");
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "There isn't a player in this car");
}
}
return 1;
}
When someone requires there car fixed someone from the assistance team can do /fixveh near their car and it shows a dialog confirming the fix..
PHP код:
case FIX_D:
{
if (!response) return SendClientMessage(playerid, 0xFF0000FF, "You cancelled.");
if(response)
{
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, COLOR_WHITE, "Your Vehicle has been repaired.");
GivePlayerMoney(playerid, -500);
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
}
}
This works aboslutely fine, however how would i award the player that sent the command(/fixveh) money?
Thanks in advance
Re: setting player cash -
DBan - 03.11.2012
Just use
https://sampwiki.blast.hk/wiki/Function:GivePlayerMoney.
Re: setting player cash -
Stu1 - 03.11.2012
How? It gives the player id -500 but i need to give the guy that reuels the car 500
Re: setting player cash -
DBan - 03.11.2012
pawn Код:
GivePlayerMoney(playerid, 500);
Very simple.
EDIT: Oh, I think I get where you're coming from, you don't have anywhere to put this to give the player typing the command money. I'll try and draft up something.
Re: setting player cash -
Stu1 - 03.11.2012
Thank you
Re: setting player cash -
DBan - 03.11.2012
There may be more efficient/better ways to do this, but this was the only way I could think of. Which is the use of player variables.
pawn Код:
new bool:helped[MAX_PLAYERS]; //Top of script
pawn Код:
CMD:fixveh(playerid, params[])
{
new vehicleid;
vehicleid = GetClosestVehiclePolice(playerid);
for (new checkvehicle; checkvehicle < MAX_PLAYERS; checkvehicle++)
if(IsPlayerInVehicle(checkvehicle, vehicleid))
{
if(gTeam[playerid] == ASSISTANCE) // Learn how to use if statements
{
ShowPlayerDialog(checkvehicle, FIX_D, DIALOG_STYLE_MSGBOX, "Repair", "Would you like your vehicle repaired?", "Yes", "No");
SendClientMessage(playerid, -1,"Repair request sent!");
SetPVarInt(playerid, "Helped", checkvehicle); //Put the player-being-helped's id into a player variable.
helped[playerid] = true; //Set the helper's helped variable to true (for use in the dialog response)
}
else
{
SendClientMessage(playerid, -1, "There isn't a player in this car");
}
}
return 1;
}
pawn Код:
case FIX_D:
{
if (!response) return SendClientMessage(playerid, 0xFF0000FF, "You cancelled.");
if(response)
{
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, -1, "Your Vehicle has been repaired.");
GivePlayerMoney(playerid, -500);
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
foreach(new i : Player)
{
if(GetPVarInt(i, "Helped") == playerid && helped[i] == true) //This checks if the helper has helped playerid, and if his helped variable is set to true.
{
GivePlayerMoney(i, 500); // Give helper his money
helped[i] = false; // and set his helped variable to false (since he hasn't helped anyone)
}
}
}
}
Let me know if you have any trouble.
Re: setting player cash -
Stu1 - 03.11.2012
Thanks for this, Looks similar to something i tried(but might actually work) I'll test it after work.