Advertisement
Guest User

send

a guest
Oct 20th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. public Action:Command_SendCredits(client, args)
  2. {
  3. if(client == 0)
  4. {
  5. PrintToServer("%t","Command is in-game only");
  6. return Plugin_Handled;
  7. }
  8.  
  9. if(args < 2) // Not enough parameters
  10. {
  11. ReplyToCommand(client, "[SM] Use: sm_send <#userid|name> [amount]");
  12. return Plugin_Handled;
  13. }
  14.  
  15. decl String:arg2[10];
  16. GetCmdArg(2, arg2, sizeof(arg2));
  17.  
  18. new amount = StringToInt(arg2);
  19.  
  20. decl String:strTarget[32]; GetCmdArg(1, strTarget, sizeof(strTarget));
  21.  
  22. decl String:strTargetName[MAX_TARGET_LENGTH];
  23. decl TargetList[MAXPLAYERS], TargetCount;
  24. decl bool:TargetTranslate;
  25.  
  26. if ((TargetCount = ProcessTargetString(strTarget, client, TargetList, MAXPLAYERS, COMMAND_FILTER_CONNECTED,
  27. strTargetName, sizeof(strTargetName), TargetTranslate)) <= 0)
  28. {
  29. ReplyToTargetError(client, TargetCount);
  30. return Plugin_Handled;
  31. }
  32. for (new i = 0; i < TargetCount; i++)
  33. {
  34. new iClient = TargetList[i];
  35. if (IsClientInGame(iClient))
  36. {
  37. if (g_iCreditos[client] < amount)
  38. PrintToChat(client, "[ SHOP ] You don't have so many credits");
  39. else
  40. {
  41. g_iCreditos[client] -= amount;
  42. g_iCreditos[iClient] += amount;
  43. PrintToChat(client, "[ SHOP ] You give \x03%i \x01credits for player: %N", amount, iClient);
  44. PrintToChat(iClient, "[ SHOP ] You get \x03%i \x01credits from player: %N", amount, client);
  45. }
  46. }
  47. }
  48. return Plugin_Continue;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement