How to Check player Score ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to Check player Score ? (
/showthread.php?tid=552893)
How to Check player Score ? -
Adarsh007 - 27.12.2014
Hey Guys ! I Just need a tiny help-
I want to Check Player Score when he types /buy So If player have 200 score then he can buy and if he have lower than 200 score then he can't buy.
What to do here is the code of /buy
Код:
COMMAND:buyhouse(playerid, params[])
{
// Setup local variables
new Msg[128];
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// Check if the player isn't inside a vehicle (the player must be on foot to use this command)
if (GetPlayerVehicleSeat(playerid) == -1)
{
// Check if the player is near a house-pickup
for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
{
// Check if the house exists
if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
{
// Check if the player is in range of the house-pickup
if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
{
// Check if the house isn't owned yet
if (AHouseData[HouseID][Owned] == false)
{
// Check if the player can afford this house
if (INT_GetPlayerMoney(playerid) >= AHouseData[HouseID][HousePrice])
House_SetOwner(playerid, HouseID); // Give ownership of the house to the player (if he has a spare houseslot)
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot afford this house"); // The player cannot afford this house
}
else
{
// Let the player know that this house is already owned by a player
format(Msg, 128, "{FF0000}This house is already owned by {FFFF00}%s", AHouseData[HouseID][Owner]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
// The player was in range of a house-pickup, so stop searching for the other house pickups
return 1;
}
}
}
// All houses have been processed, but the player wasn't in range of any house-pickup, let him know about it
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}To buy a house, you have to be near a house-pickup");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't buy a house when you're inside a vehicle");
// Let the server know that this was a valid command
return 1;
}
I want that Player Must have 200 Score to use this command.
Re: How to Check player Score ? -
Evocator - 27.12.2014
pawn Код:
COMMAND:buyhouse(playerid, params[])
{
// Setup local variables
new Msg[128];
if (GetPlayerScore(playerid) < 200) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need at least 200 scores to buy a house.");
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// Check if the player isn't inside a vehicle (the player must be on foot to use this command)
if (GetPlayerVehicleSeat(playerid) == -1)
{
// Check if the player is near a house-pickup
for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
{
// Check if the house exists
if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
{
// Check if the player is in range of the house-pickup
if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
{
// Check if the house isn't owned yet
if (AHouseData[HouseID][Owned] == false)
{
// Check if the player can afford this house
if (INT_GetPlayerMoney(playerid) >= AHouseData[HouseID][HousePrice])
House_SetOwner(playerid, HouseID); // Give ownership of the house to the player (if he has a spare houseslot)
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot afford this house"); // The player cannot afford this house
}
else
{
// Let the player know that this house is already owned by a player
format(Msg, 128, "{FF0000}This house is already owned by {FFFF00}%s", AHouseData[HouseID][Owner]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
// The player was in range of a house-pickup, so stop searching for the other house pickups
return 1;
}
}
}
// All houses have been processed, but the player wasn't in range of any house-pickup, let him know about it
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}To buy a house, you have to be near a house-pickup");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't buy a house when you're inside a vehicle");
// Let the server know that this was a valid command
return 1;
}
Re: How to Check player Score ? -
HY - 27.12.2014
pawn Код:
if(GetPlayerScore(playerid)) >= 200)
{
// Codes
}